mirror of https://github.com/mkerrisk/man-pages
getline.3: EXAMPLE: specify file to be opened as command-line argument
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
71fd04a347
commit
cbc616e345
|
@ -165,14 +165,19 @@ They were standardized in POSIX.1-2008.
|
|||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
FILE *stream;
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
ssize_t nread;
|
||||
|
||||
stream = fopen("/etc/motd", "r");
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s <file>\en", argv[1]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
stream = fopen(argv[1], "r");
|
||||
if (stream == NULL)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue