C and POSIX read / write
avp@avp-ubu1:hashcode$ cat golf.c main(){char s[4]; write(1, s, read(0, s, 4));} avp@avp-ubu1:hashcode$ wc golf.c 1 7 47 golf.c avp@avp-ubu1:hashcode$ gcc golf.c -Wno-implicit-function-declaration -Wno-implicit-int avp@avp-ubu1:hashcode$ echo 123 | ./a.out 123 avp@avp-ubu1:hashcode$
With the loss of readability is easily reduced to 40 characters:
main(){int s;write(1,&s,read(0,&s,4));}
Update
At the hint @pavel in the comments turned out 35 !!! (and that is characteristic, without warnings -), and the -w flag was enough
avp@avp-ubu1:hashcode$ gcc golf.c -w avp@avp-ubu1:hashcode$ cat golf.c s; main(){write(1,&s,read(0,&s,4));} avp@avp-ubu1:hashcode$
Thank you, @pavel
b;main(){puts((read(0,&b,4),&b));}
using hints from all answers and comments - 34 (!) characters
Oddly enough, gcc -w compiles altogether without swearing, and ./a.out works -)
INPUT.TXT, then the output file ... - VTTstd::cout << std::cin.rdbuf();already read harder, because There are two actions on the same line, and this code is unlikely to occur on a real project. - goldstar_labsintfrom themaindeclaration. This is forbidden in both C and C ++, but GCC "misses." And now the code has become shorter ... - AnT