Write a Program in C that prints itself?
[code:1]char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);} [/code:1]
A C quine must have a printf since it needs to print itself and its hard to write one with ' " ' in it.
34 is basically the ASCII value of "
Now if you expand the ASCII values and 'f' for its actual values in printf(f,34,f,34,10); it becomes self-explantory
pLEASE EXPLAIN THE BASIC LOGIC
programs that print itself are called Quines..
This is a classic C Quine
char*f="char*f=%c%s%c;main() {printf(f,34,f,34,10);}%c"; main(){printf(f,34,f,34,10);}
The are many varitions to this though
Write a Program in C that prints itself?
[code:1]char*f="char*f=%c%s%c;main()
{printf(f,34,f,34,10);}%c";
main(){printf(f,34,f,34,10);} [/code:1]
A C quine must have a printf since it needs to print itself and its hard to write one with ' " ' in it.
34 is basically the ASCII value of "
Now if you expand the ASCII values and 'f' for its actual values in printf(f,34,f,34,10); it becomes self-explantory
eXPLAIN THE LOGIC PLEASE
pLEASE EXPLAIN THE BASIC LOGIC
Quines
programs that print itself are called Quines..
This is a classic C Quine
char*f="char*f=%c%s%c;main()
{printf(f,34,f,34,10);}%c";
main(){printf(f,34,f,34,10);}
The are many varitions to this though