How do you write a program which produces its own source
code as its output?
Answer Posted / yogesh bansal
#include <stdio.h>
int main()
{
FILE *file;
char filename[]="outputsourcecode.c";
char str[125];
file=fopen(filename,"r");
if(file == NULL)
{
printf("cannot open the file");
exit(1);
}
while(!feof(file))
{
if(fgets(str,125,file))
{
printf("%s", str);
}
}
return 0;
}
this is a working code.
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is the difference between #include
Are negative numbers true in c?
What is the difference between typedef and #define?
What is context in c?
Can we access the array using a pointer in c language?
What are the different types of control structures in programming?
how we can make 3d venturing graphics on outer interface
List some of the static data structures in C?
What are the key features in c programming language?
Why malloc is faster than calloc?
Is c procedural or object oriented?
What do you understand by normalization of pointers?
What is volatile variable how do you declare it?
What are the advantages of using Unions?
How many types of operators are there in c?