#define _GNU_SOURCE #include #include int main (int argc, char **argv) { char *line = NULL; size_t len; FILE *fp; if (argc != 2) { fprintf (stderr, "Exactly one argument required, namely the filename \n"); exit (1); } fp = fopen (argv[1], "r"); if (fp == NULL) { fprintf (stderr, "%s: Couldn't open file %s!\n", argv[0], argv[1]); exit (1); } while (getline (&line, &len, fp) != -1) { printf ("The next line is %s", line); free (line); line = NULL; } exit (0); }