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
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
What is c value paradox explain?
What are loops in c?
How #define works?
Why do we need a structure?
What is pointer to pointer in c language?
Differentiate between null and void pointers.
what is the different bitween abap and abap-hr?
What is the equivalent code of the following statement in WHILE LOOP format?
What are the different types of objects used in c?
What are the disadvantages of c language?
Tell me what are bitwise shift operators?
What does *p++ do? What does it point to?
What is the use of pragma in embedded c?
What is a void pointer in c?