How do you write a program which produces its own source
code as its output?

Answer Posted / vivek

printitself.c

#include <stdio.h>

int main()
{

char ch;
FILE *file;

file=fopen("printitself.c","r");

while((ch=fgetc(file))!=EOF)
printf("%c",ch);

return 0;
}

Is This Answer Correct ?    19 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What's a good way to check for "close enough" floating-point equality?

630


What is a built-in function in C?

800


How to write a multi-statement macro?

629


Which built-in library function can be used to match a patter from the string?

749


What are data types in c language?

590






When should structures be passed by values or by references?

588


What is NULL pointer?

680


using for loop sum 2 number of any 4 digit number in c language

1738


how can use subset in c program and give more example

1507


Why clrscr is used in c?

591


What is the purpose of realloc()?

676


What does c mean in basketball?

564


What is wrong with this initialization?

597


What does a pointer variable always consist of?

667


What are the advantages of using macro in c language?

596