The smallest code that prints itself : (In the question, the format of the output was not specified. So, the program prints itself in binary (not 0s & 1s) but ASCII codes of the binary). The code is C++ code as it uses iostream; but can be converted to C easily. But this is just a guess & not a definite solution.
#include<iostream.h>
void main()
{
void (*f_ptr)()=main;
char *ptr=(char *)f_ptr;
cout << ptr;
}
Any other answers/corrections in above code ? Please post.
[/code]
#include<iostream.h>
void main()
{
void (*f_ptr)()=main;
char *ptr=(char *)f_ptr;
cout << ptr;
}
Any other answers/corrections in above code ? Please post.
[/code]