C code include from stdin

I saw claim that you can include /dev/stdin in C/C++ code compiled with gcc at Facebook posting

https://m.facebook.com/groups/2344226875800424?view=permalink&id=2591966714359771

That post made reference to article

https://blog.hboeck.de/archives/898-include-etcshadow.html

It looked interesting so here is my version of C code that includes some data/code from stdin at compile time:

#include <stdio.h>
int main() {
printf(“%s\n”,
#include “/dev/stdin”
);
return 0;
}

/*
GCC code that does include from stdin
Tested with gcc (GCC) 4.8.5 20150623

Compiling and runnning commands:

echo ‘”Hello, world!”‘ > in
gcc a.c < in && ./a.out

*/

0 Comments

Be the first to post a comment.

Leave a Comment

Your email address will not be published. Required fields are marked *

*

*