stdio.h is a built-in header file in C that gives us functions to handle input and output. See this link for documentation.

Data types

  • FILE: for file streams. See macros below.

Macros

  • stdin and stdout are pointers to type FILE, corresponding to the standard input (generally by default the keyboard) and output streams respectively.
  • stderr is similarly a FILE pointer for the standard error. In general we should send error messages to this instead of stdout.

Functions

  • int puts(const char *str): takes a pointer to a string and prints the entire string from index 0 to the null character.
  • char *gets(char *str): takes a pointer to an array of characters, reads all white spaces, and won’t read the enter key. Will buffer overflow if more characters are entered than there is space.
  • char *fgets(char *str, int n, FILE *stream): takes a pointer to an array of characters and reads only the specified number of characters. It does append the null character to the end!