GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  OOPS

 Print  |  
Question:  How do you write a program which produces its own source code as its output?



July 07, 2005 00:02:55 #2
 Anjaneyulu   Member Since: Visitor    Total Comments: N/A 

RE: How do you write a program which produces its own source code as its output?
 
/* Program to printf itself on console */ 
#include  
int main(void) 

FILE *in; 
clrscr(); 
if ((in = fopen("8.c", "r")) == NULL) 

printf("Cannot open input file.n"); 
return 1; 

while (!feof(in)) 
printf("%c", fgetc(in)); 
fclose(in); 
getche(); 
return 0; 

     

 

Back To Question