Skip to main content

C, 48 bytes

C, 48 bytes

main(c){for(c=8192;read(0,&c,1);write(1,&c,2));}
main(c){for(c=8192;read(0,&c,1);write(1,&c,2));}

Try it onlineTry it online

  • main(c) declares the main function that takes one argument c. If the data type is not specified, everything is an int. Therefore c is an int variable.
  • The main routine consists of one for statement, for(…);. The body of the for loop is empty, everything happens inside the control header.
  • c=8192 initialize c to the value 32 * 256. 32 is the ordinal value of a space character. 256 shifts the value 8 bits to the left (more significant places).
  • read(0,&c,1) reads 1 Byte from STDIN (0) to the address of c (&c). This command returns a successful status as long as there is input to read.
  • Provided the read is successful, write(1,&c,2) writes 2 Bytes that are stored at the address of c to STDOUT (1).

C, 48 bytes

main(c){for(c=8192;read(0,&c,1);write(1,&c,2));}

Try it online

C, 48 bytes

main(c){for(c=8192;read(0,&c,1);write(1,&c,2));}

Try it online

  • main(c) declares the main function that takes one argument c. If the data type is not specified, everything is an int. Therefore c is an int variable.
  • The main routine consists of one for statement, for(…);. The body of the for loop is empty, everything happens inside the control header.
  • c=8192 initialize c to the value 32 * 256. 32 is the ordinal value of a space character. 256 shifts the value 8 bits to the left (more significant places).
  • read(0,&c,1) reads 1 Byte from STDIN (0) to the address of c (&c). This command returns a successful status as long as there is input to read.
  • Provided the read is successful, write(1,&c,2) writes 2 Bytes that are stored at the address of c to STDOUT (1).
Source Link
xsot
  • 5.5k
  • 1
  • 16
  • 24

C, 48 bytes

main(c){for(c=8192;read(0,&c,1);write(1,&c,2));}

Try it online