Pages

Monday, February 17, 2014

Program which produces its own source code as output.

This c program produces its own source code as its output
such a program is called a quine.This kind of program takes no input and produces a copy of its own source code as its only output.


#include <stdio.h>
int main(){
FILE  *fp;
char c;
fp=fopen(_FILE_,"r");
do{
       c=getc(fp);
       putchar(c);

}while(c!=EOF)

fclose(fp);
return 0;

}


output

#include <stdio.h>
int main(){
FILE  *fp;
char c;
fp=fopen(_FILE_,"r");
do{
       c=getc(fp);
       putchar(c);

}while(c!=EOF)

fclose(fp);
return 0;

}


No comments: