💾 Archived View for thrig.me › blog › 2023 › 05 › 07 › getaline.c captured on 2023-05-24 at 18:09:59.
-=-=-=-=-=-=-
#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); }