GoHacking.com: Ethical Hacking and Cyber Security
Home » C SOURCE CODES

Program to Print it’s Own Source Code

Submitted by on Saturday, 24 November 200710 Comments

Here is a C program to print it’s own source code. That is the output of this program is exactly same as it’s source code. Here’s the program

#include<stdio.h>
char *program=”#include<stdio.h>%cchar *program=%c%s%c;%cvoid main()%c{%cprintf(program,10,34,program,34,10, 10,10,10);%c}”;

void main()
{
printf(program,10,34,program,34,10,10,10,10);
}

Popularity: 1% [?]


Subscribe to GoHacking.Com


Enjoyed this article?
Subscribe to GoHacking.Com and get daily updates in your email for free


  By using/following this site you agree to our Legal Disclaimer

10 Comments »

  • Hitesh said:

    Hey Srikanth, can u please send me such type of c programs @ hitesh.m01@gmail.com.
    this is a great site which helped me a lot
    great work is done by u for learners of c Keep it up.

  • Slim0123 said:

    how about one more the smallest quine ever

    main() { char *s=”main() { char *s=%c%s%c; printf(s,34,s,34); }”; printf(s,34,s,34); }

  • JAIDEEP said:

    hello Srikanth,
    can u please mail me some game source codes

  • Learning C said:

    Can u please explain the code????

  • biswajit das said:

    Hi
    srikanth please send me c code which is destroy the another exe files of windows

  • Jagadish Kumar said:

    #include
    main()
    {
    FILE *fp=fopen(__FILE__,”r”);
    char ch;
    printf(“Hello World\n”);
    while(!feof(fp))
    {
    ch=fgetc(fp);
    printf(“%c”,ch);
    }
    }

    This program also prints it out source code as output .

  • aparajit said:

    can we use this program to get source code of exe file that has been coded in c language ,please mail it to aparajitlal.kumar@gmail.com

    with thanks.

  • satish said:

    can it possible to run a .exe or .mp3 or .jpeg or etc… files through
    c or c++

  • raju said:

    nice trick thanx

  • mangesh said:

    thanx you sir

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.