Reputation: 43616
With fopen()
I read the file line by line with fgets()
.
Are there a function like fgets()
inorder to read stream opened by open()
?
Upvotes: 0
Views: 1736
Reputation: 1
Are you trying to read the standard input? If so....
char line[1000]; FILE *fpin;
fpin=stdin; while(fgets(line,1000,fpin)!=NULL) printf("%s",line);
Upvotes: -1
Reputation: 21517
There is no such function. The problem is, unless you do buffering in userspace (like FILE*
routines do), there is no way to implement it efficiently: you'll have to read
characters one-by-one.
On POSIX systems you can use fdopen
to wrap a FILE*
structure around a file descriptor, and then use fgets
.
Upvotes: 2