A programm that displays its source
A programm that displays its source. Compile, run executiable, and it will show the source code from wich it has been compiled. Just for fun...Useless, i guess ;)
AI
Resumo por IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Código fonte
#include <stdio.h>
char szMyCode[] =
"void printf_strconst( char* str )\n"
"{\n"
" do\n"
" {\n"
" switch( *str )\n"
" {\n"
" case \'\\n\':\n"
" printf(\"\\\\n\\\"\");\n"
" if( *(str+1) )\n"
" printf(\"\\\"\");\n"
" break;\n"
" case \'\\\"\':\n"
" printf(\"\\\"\");\n"
" break;\n"
" case \'\\\'\':\n"
" printf(\"\\\'\");\n"
" break;\n"
" case \'\\\\\':\n"
" printf(\"\\\\\\\\\");\n"
" break;\n"
" case \'%\':\n"
" printf(\"%%\");\n"
" str++;\n"
" break;\n"
" default:\n"
" printf( \"%c\", *str );\n"
" }\n"
" }\n"
" while( *++str );\n"
" printf( \";\\n\\n\" );\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" printf( \"#include <stdio.h>\\n\\nchar szMyCode[] =\\n\\\"\" );\n"
" printf_strconst( szMyCode );\n"
" printf( \"%s\",szMyCode );\n"
" printf( \"-=== THIS IS MY SOURCE! Press any key ===-\");\n"
" getchar();\n"
"}\n";
void printf_strconst( char* str )
{
do
{
switch( *str )
{
case '\n':
printf("\\n\"");
if( *(str+1) )
printf("\n\"");
break;
case '\"':
printf("\\\"");
break;
case '\'':
printf("\\\'");
break;
case '\\':
printf("\\\\");
break;
case '%':
printf("%%");
break;
default:
printf( "%c", *str );
}
}
while( *++str );
printf( ";\n\n" );
}
void main()
{
printf( "#include <stdio.h>\n\nchar szMyCode[] =\n\"" );
printf_strconst( szMyCode );
printf( "%s",szMyCode );
printf( "-=== THIS IS MY SOURCE! Press any key ===-");
getchar();
}
Comentários originais (3)
Recuperado do Wayback Machine