A self-printing program (quine).
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;
}
On 11/15/2024 5:54 AM, Muttley@DastartdlyHQ.org wrote:
c
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;$
ase 63:$ printf(@%s@,prog);$break
;$$ default:$ putchar(*c);$I believe you can elide the #include <string.h> texts.
}$ }$ 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;
}
As to the OP, yeah, not only that, but we have no clue what's in "Wy.h"
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 58:59:25 |
Calls: | 10,397 |
Calls today: | 5 |
Files: | 14,067 |
Messages: | 6,417,461 |
Posted today: | 1 |