How to write a program which prints its own source code as output?

Questions by rabia.sultana14

Showing Answers 1 - 1 of 1 Answers

_jawahir_

  • Jun 17th, 2011
 

//***************jawahir007***************//
#include<stdio.h>
#include<conio.h>
void main(int argc, char *argv[])
{
 char ch,*f,i;
 FILE *fp;
 clrscr();
 for(i=0;argv[0][i]!='.';i++)
 f[i]=argv[0][i];
 f[i]='.';
 f[++i]='C';
 f[++i]='';
 fp=fopen(f,"r");
 while(!feof(fp))
 {
 ch=getc(fp);
 putchar(ch);
 }
 fclose(fp);
 getch();
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions