Source Code Output

Write a program which produces its own source code as its output?

Questions by rakeshrm3010

Showing Answers 1 - 12 of 12 Answers

Vani .K.R

  • Oct 28th, 2010
 

#include<stdio.h>

main()
{
   FILE *input = fopen("a.c", "r");
   char buf[30];
   while (fgets(buf, 30, input))
  printf(buf);
   getch();
}

  Was this answer useful?  Yes

#include #includemain(int arg, char *arr[]){ FILE *pFile; clrscr(); int c; pFile=fopen ("abhishek.cpp","r"); if (pFile==NULL) perror ("Error opening file"); else { do { c = getc (pFile); printf("%c",c); } while (c != EOF); fclose (pFile); } getch();return 0;}

  Was this answer useful?  Yes

//File should be save as abhishek.cpp#include #includemain(int arg, char *arr[]){ FILE *pFile; clrscr(); int c; pFile=fopen ("abhishek.cpp","r"); if (pFile==NULL) perror ("Error opening file"); else { do { c = getc (pFile); printf("%c",c); } while (c != EOF); fclose (pFile); } getch();return 0;}

  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