View Single Post
  #3 (permalink)  
Old 12-21-2007, 12:34 PM
Freedom Doc Freedom Doc is offline
Newbie
 
Join Date: Dec 2007
Posts: 8
Credits: 0
Rep Power: 0
Freedom Doc is on a distinguished road
Default

Quote:
Originally Posted by WingedPanther View Post
Try using the getline() function.
The OP said he was using C. There is no getline() in C.
(If the OP is cool with using C++ he should say so).

To the OP: if you just need to read a sentence into a string, try fgets:

fgets(buff, 80, stdin);

would read 80 chars from stdin, or up to end of line or end of file, whatever comes first.
What it reads goes into buff, which should be declared
char buff[81];
If you want to read such a string from a file, say FILE *f then just say
fgets(buff, 80, f);
assuming f has been opened.

Last edited by Freedom Doc; 12-21-2007 at 12:51 PM. Reason: Needed to say more
Reply With Quote