C Commands
The C language, its standard library and compilers.All C pages
- c convert string to int safely with strtol (not atoi)Convert a string to an int in C with strtol and proper checks for no digits, trailing text and overflow (errno ERANGE), and why atoi cannot report errors.
- c read a file line by line with fgets (and getline)Read a text file line by line in C with fopen and fgets, strip the newline with strcspn, or use POSIX getline for long lines. Error checks and the feof trap.
- gcc hello.c -o hello: compile and run a C programCompile and run a C program with gcc hello.c -o hello and ./hello. The options that matter: -Wall -Wextra, -std, -O2, -g, -lm, sanitizers, and common errors.
- gcc main.c util.c -o app: compile and link multiple C filesCompile and link several C files with gcc main.c util.c -o app, or separately with -c and object files. Header files, -I, include guards and linker errors.