C notes

Random C notes.

The getline/getdelim functions

It is possible to put a dynamic width specifier to printf using .* in the format string. This is useful, for example, to print a just read line without the newline character.

char *line = NULL;
size_t alloc_len;
getline(&line, &alloc_len, stdin);
printf("<%.*s>\n", recordline);