Input and output

#include <stdio.h>

....printf("Decimal %d = Octal 0%o = Hexadecimal 0x%x\n",
........a, a, a);

....fprintf(stderr, "Error %d: %s\n",
........error_number, error_message[error_number]);

....scanf("%s %d", last_name, &age);

The shell sets up three standard I/O streams when you run a program:
stdin -- the standard input, stdout -- the standard output, and
stderr -- the standard error output. Normally stdin is your key
-board, stdout is your screen, and stderr is also your screen, but this
can be changed using pipes and redirection.

The first argument to fprintf is a stream.

The arguments to scanf must be pointers.
scanf("%d", age); will cause a mysterious runtime error.


/* copy input to output */

#include <stdio.h>

main()
{
int c;

....while ((c=getchar()) != EOF)
........putchar(c);
}


getchar() returns an int, not a char. This allows it to return a flag
value EOF when you try to read past the end of the file.

EOF is defined in stdio.h.

To produce EOF from your keyboard, type control-D.