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 header file in c?
What are dangling pointers in c?
Explain what is the difference between a free-standing and a hosted environment?
What is huge pointer in c?
What is a stream in c programming?
Explain what are reserved words?
What is a volatile keyword in c?
By using C language input a date into it and if it is right?
What is the use of a static variable in c?
What is the c value paradox and how is it explained?
Why n++ execute faster than n+1 ?
Is null equal to 0 in sql?
What is a 'null pointer assignment' error?
What is main function in c?
Are enumerations really portable?