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
How do you determine the length of a string value that was stored in a variable?
What is LINKED LIST? How can you access the last element in a linked list?
What is an lvalue?
Why static variable is used in c?
a c code by using memory allocation for add ,multiply of sprase matrixes
Is main is user defined function?
What is data structure in c language?
What is difference between class and structure?
Distinguish between actual and formal arguments.
How macro execution is faster than function ?
What are header files in c?
What is the use of define in c?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
How can I run c program?