C/C++ program that prints its own source code as its output

后端 未结 8 2270
天命终不由人
天命终不由人 2020-11-29 08:25

Wikipedia says it\'s called a quine and someone gave the code below:

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


        
8条回答
  •  攒了一身酷
    2020-11-29 09:25

    You can also define printf's prototype by hand.

    const char *a="const char *a=%c%s%c;int printf(const char*,...);int main(){printf(a,34,a,34);}";int printf(const char*,...);int main(){printf(a,34,a,34);}
    

提交回复
热议问题