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
Explain low-order bytes.
What are linked lists in c?
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
What is a nested loop?
Compare and contrast compilers from interpreters.
What is a header file?
How do you determine whether to use a stream function or a low-level function?
Can i use “int” data type to store the value 32768? Why?
What is break in c?
What does 3 periods mean in texting?
What is declaration and definition in c?
What is the difference between struct and union in C?
What are the advantages of c language?
Explain high-order and low-order bytes.
Why enum is used in c?