How do you write a program which produces its own source
code as its output?
Answer Posted / abhishek
#include <stdio.h>
static char prog[] = "#include <stdio.h>%c%cstatic char prog[] = %c%s%c;%c%cint main(void)%c{%c printf(prog, 10, 10, 34, prog, 34, 10, 10, 10, 10, 10, 10, 10);%c return 0;%c}%c";
int main(void)
{
printf(prog, 10, 10, 34, prog, 34, 10, 10, 10, 10, 10, 10, 10);
return 0;
}
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
What are the general description for loop statement and available loop types in c?
Can you add pointers together? Why would you?
What is structure padding in c?
Are pointers integers in c?
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
What is an endless loop?
explain what are actual arguments?
What is the importance of c in your views?
please send me the code for multiplying sparse matrix using c
I need testPalindrome and removeSpace
#include
Explain how can a program be made to print the line number where an error occurs?
what do u mean by Direct access files? then can u explain about Direct Access Files?
Tell me is null always defined as 0(zero)?
What is scanf_s in c?
What are the two types of structure?