Print your own program

Source: Internet
Author: User

Brief # include <stdio. h>

Main () {char * s = "# include <stdio. h> % cmain () {char * s = % c % s % c; printf (s, 10, 34, s, 34) ;}"; printf (s, 10, 34, s, 34 );}

 

Reference http://hi.baidu.com/atyuwen/blog/item/318ceb9b688ea7b2c8eaf412.html#0

 

'\ "' Uses a slash

Main () {char * a = "main () {char * a = % c % s % c; printf (a, 34, a, 34 );}"; printf (a, 34, a, 34);} '\ "' uses printf (" % c ", 34); Output

'\ N' can use printf ("% c", 10); Output

 

 

 

Easy to read # include <stdio. h>

Main (){

Char * s = "# include <stdio. h> % cmain () {% c % cchar * s = % c % s % c; % c % cprintf (s, 10, 10, 9, 34, s, 34, 10, 9, 10 ); % c }";

Printf (s, 10, 10, 9, 34, s, 34, 10, 9, 10 );

}

// Copyright (c) LeafCore

# Include <stdio. h>

Void main (){

Char * s = "// Copyright (c) LeafCore % c # include <stdio. h> % cvoid main () {% c % cchar * s = % c % s % c; % c % cprintf (s, 10, 10, 9, 34, s, 34,10, 9, 10); % c }";

Printf (s, 10, 10, 10, 9, 34, s, 34, 10, 9, 10 );

}

What a fantasy!

Executable files generate their own source files

// Copyright (c) LeafCore

# Include <stdio. h>

Main (){

FILE * fp = fopen ("file. c", "w ");

Char * s = "// Copyright (c) LeafCore % c # include <stdio. h> % cmain () {% c % cFILE * fp = fopen (% cfile. c % c, % cw % c); % c % cchar * s = % c % s % c; % c % cfprintf (fp, s, 10, 10, 9, 34,34, 34,34, 34, s, 34,10, 9,10, 9,10, 9,10); % c % cfclose (fp); % c % creturn 0; % c }";

Fprintf (fp, s, 10, 10, 9, 34, 34, 34, 34, 10, 9, 34, s, 34, 10, 9, 10, 9, 10 );

Fclose (fp );

Return 0;

} Run the generated executable file to generate its own source file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.