我在 Ken Thompson 的一篇文章(阅读此处)中看到的这个 quine并没有重现相同的代码。我只是好奇为什么它不起作用?代码现在过时了吗?
奎因代码:
char s[] = {
'\t',
'0',
'\n',
'}',
';',
'\n',
'\n',
'/',
'*',
'\n'
};
/*
*The string s is a representation of the body
*of this program from '0'
* to the end
*/
main(){
int i;
printf("char\ts[] = {\n");
for(i = 0; s[i]; i++)
printf("\t%d, \n", s[i]);
printf("%s",s);
}
输出:
char s[] = {
9,
48,
10,
125,
59,
10,
10,
47,
42,
10,
0
};
/*
这些是编译时的编译器警告(self_reproducing.c
是文件名):
self_reproducing.c:20:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
20 | main(){
| ^~~~
self_reproducing.c: In function ‘main’:
self_reproducing.c:23:2: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
23 | printf("char\ts[] = {\n");
| ^~~~~~
self_reproducing.c:23:2: warning: incompatible implicit declaration of built-in function ‘printf’
self_reproducing.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
+++ |+#include <stdio.h>
1 | char s[] = {
哎呀!我忽略了这213 lines deleted
条线。所以问题应该是——<strong>文章中提到的整个 quine 是什么?