A C program that prints itself.
Click for Solution

  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 681
    A #include<stdio.h>
    #include<conio.h>
    void main()
    {
    char c;
    FILE *fp;
    clrscr();
    fp=fopen("d:\\abhi\\holeprg.cpp","r+");
    do
    {
    c=(char)fgetc(fp);
    putchar(c);
    } while(c!=EOF);
    getch();
    printf("I AM INDIAN");
    }

    // NOTE:- U MUST REFER TO YOUR PROGRAM WHICH U R TYPING 'in the absolute path ' mentioned above


  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 681
    A void main() { FILE *fp; char ch; fp=fopen(_FILE_,r); while(1) { ch=fgetc(fp); if(ch==EOF) break; else printf("%c",ch); } fclose(fp); }

    CpjJwWHV   Google for "Quine". Quine is a program that prints itself. There is a wikipedia entry for it. It has got sample programs as well ass the logic to write such programs :)
    14 years ago
    CpjJwWHV   very nice approach ....
    14 years ago
    CpjJwWHV   its not working.......
    14 years ago

    Smiley

[Insert Code]