C++ Mania

Miscellaneous problems and features of C/C++

Thursday, December 30, 2010

Can you write a program which produces own source code as output ?

#include <stdio.h>
void main()
 {
   FILE *fd;
   int c;

   fd= fopen("./itself.c","r");
   while ( (c=fgetc(fd)) != EOF)
     {
       printf("%c", c);
     }
  
fclose(fd);
}
Posted by Amit Raj at 9:29 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Example

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Search This Blog

Links

  • Subscribe to SMS

Dennis M. Ritchie

Dennis M. Ritchie

About Me

My photo
Amit Raj
View my complete profile

Labels

  • advanced (1)
  • Concept (8)
  • Example (10)
  • First Post (1)
  • Function Overloading (1)
  • HelloWorld (1)
  • Pure Virtual Function (1)
  • Questions (1)
  • Virus using C (1)

Blog Archive

  • ▼  2010 (16)
    • ▼  December (16)
      • My First Post
      • A "Hello World" program
      • Does C supports function overloading like C++ ?
      • What's a pure virtual function ?
      • Will this code compile ?
      • Can you tell if the given number is even or odd ?
      • Can you Create a Virus in C ?
      • Can you Count the Number of bits set in an integer ?
      • Write a C program to show day and time
      • Power Of Two
      • Write a C program to convert Decimal to Hex
      • Creating CON folder in windows
      • Reading and Writing Serial Port
      • Some Good Questions
      • Can you write a program which produces own source ...
      • Can you write a program whice invoke another C pro...
  • ►  2011 (1)
    • ►  February (1)
free counters

Feed

Visits

2,911
Ethereal theme. Powered by Blogger.