On Fri, 15 Nov 2024 20:45:58 +0800
wij <
[email protected]> boring babbled:
A self-printing program (quine).
Hell it is. It has to print out the whole code, not just the main() function.
Heres one that actually works:
#include <stdio.h>
#include <string.h>
int main()
{
char *prog="#include <stdio.h>$#include <string.h>$$int main()${$
char *prog=@?@;$ char *c;$$ for(c=prog;*c;++c)$ {$
switch(*c)$ {$ case 36:$
putchar(10);$ break;$ case 64:$
putchar(34);$ break;$ c
ase 63:$ printf(@%s@,prog);$ break
;$$ default:$ putchar(*c);$
}$ }$ return 0;$}$";
char *c;
for(c=prog;*c;++c)
{
switch(*c)
{
case 36:
putchar(10);
break;
case 64:
putchar(34);
break;
case 63:
printf("%s",prog);
break;
default:
putchar(*c);
}
}
return 0;
}
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)