Random notes on C
____ _
/ ___| |
| | | |
| |___|_|
\____(_)
char str[] = "";
printf("%s\n", str);
String ends with \0 (null terminator).
Get a line from a file:
char fgets(char *str, int max, FILE * file)
Sometimes it's easier to read in a line of input using fgets instead of using
scanf.
stdin
stdout -> buffered
stderr -> not buffered
stdout prints to screen when buffer becomes full, or when scanf is called, etc.
fprintf(stderr, ...);
String functions (ANSI standard string library):
#include <string.h>
size_t strlen(char * str);
returns the length of a NULL terminated characer string
size_t -- a type defined in string.h that is equivalent to an unsigned int
char a[5]={'a', 'b', 'c', 'd', 'e'};
strlen(a);