I want to know if there is any function in that reads a whole line from a file each time I use it. The file format is txt.
Having problem working with DAT files!
Collapse
X
-
Tags: None
-
Originally posted by RedSonWhat methods are you using now instead of reading the entire line? Reading an entire line is the same as reading each char until you reach a '\n' or whatever Microsoft's version of a '\n' is.
Is there any simpler way for doing that?Comment
-
Originally posted by RedSonWhat methods are you using now instead of reading the entire line? Reading an entire line is the same as reading each char until you reach a '\n' or whatever Microsoft's version of a '\n' is.
http://www.cplusplus.c om/reference/clibrary/cstdio/fgets.html
and getline() in C++
http://www.cplusplus.c om/reference/iostream/istream/getline.htmlComment
-
Example of how to use fgets/fputs(C code), function readin a line from stdin and send it to stdout , no loops:
int mygetline(char *line, int max)
{
if(fgets(line,m ax,stdin)==NULL ) return 0;
else {fputs(line,std out);
return 1;
}
}
Originally posted by mojtabasahThanks for replying.You mean I use a loop, get one character a time, concatinate them to a string until I reach a '\n' ?
Is there any simpler way for doing that?Comment
Comment