This quine I saw in an article by Ken Thompson (read here) isn't reproducing the same code. I was just curious why it's not working? is the code obsolete now?.
code of 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);
}
output:
char s[] = {
9,
48,
10,
125,
59,
10,
10,
47,
42,
10,
0
};
/*
These are the compiler warnings on compiling (self_reproducing.c
is the filename):
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[] = {
Oops! I ignored the 213 lines deleted
line. So the question should be —what is the whole quine that is mentioned in the article?