💾 Archived View for thrig.me › blog › 2023 › 05 › 07 › getaline.c captured on 2023-06-16 at 17:27:33.

View Raw

More Information

⬅️ 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);
}