program that prints itself, how does it work?

后端 未结 4 1450
旧时难觅i
旧时难觅i 2020-12-29 07:42

I came across a program that prints itself on this site, i.e. it prints the program code.

The program code is:

#include 
char *program         


        
4条回答
  •  时光取名叫无心
    2020-12-29 08:19

    Printf prints the string given as the first argument (in this case the string in *program) substituting the other arguments where you have a %s or %c

    %s means the arguement is a string, %c is a character.

    As the note says, it uses %s to print a copy of the program string inside the program string - hence making a copy, and uses the %c to print the characters 10 (new line) and 34 "

提交回复
热议问题