💾 Archived View for thrig.me › blog › 2023 › 05 › 07 › getaline.c captured on 2024-07-09 at 00:53:06.
⬅️ Previous capture (2023-05-24)
-=-=-=-=-=-=-
#include <err.h> #include <stdio.h> int main(void) { char *filename = NULL; size_t linesize = 0; ssize_t linelen = getline(&filename, &linesize, stdin); if (linelen < 0) err(1, "getline"); FILE *fh = fopen(filename, "r"); if (!fh) err(1, "fopen '%s'", filename); }