Search

Sponsored Links

Meta

Categories

Archives

Recent Posts

RSS Feeds

22
Dec

Program that prints itself

Related Blog Items

There are many obscure ways to print a program itself, Here is an understandable program which does that…

This program output will print the program itself

int main ()
{
  int c;
  FILE *f = fopen (__FILE__, "r");
 
  if (!f) 
    return 1;
 
  for (c=fgetc(f); c!=EOF; c=fgetc(f))
    putchar (c);
 
  fclose (f);
  return 0;
}

Popularity: 7%

You need to log on to convert this article into PDF


Related Blog Items

No Comments

No comments yet.

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image