Re: reading a line through scanf



gyan wrote:
>
> I want to read a line with white spaces though scanf.
> So i used:
> scanf("%['/n']",string);
>
> above is working in one program, but in other..what may be the
> reason?

Why bother - scanf is not easy to handle. If you want a complete
line, get a complete line. fgets is one was. gets is not (never
use it). Another possibility is my ggets, which is also written in
portable standard c, has the simplicity of gets together with the
complete safety (although you do have to remember to free the line
storage when you are done with it). See:

<http://cbfalconer.home.att.net/download/ggets.zip>

--
Chuck F (cbfalconer@xxxxxxxxx) (cbfalconer@xxxxxxxxxxxxxxxx)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


.



Relevant Pages

  • Re: reading a line through scanf
    ... gyan wrote: ... > I want to read a line with white spaces though scanf. ... Should you not use '\n' instead?And should you not exclude the newline ...
    (comp.lang.c)
  • Re: scanf to include white spaces
    ... > I was wondering if there was a way to include the white spaces in a string. ... variable must be an array pointer. ... scanf() stops at white space. ...
    (comp.lang.c)
  • Re: reading a line through scanf
    ... pete wrote: ... > gyan wrote: ... >> I want to read a line with white spaces though scanf. ...
    (comp.lang.c)
  • Re: reading a line through scanf
    ... > I want to read a line with white spaces though scanf. ... be made to do this it is not what it is designed for and is awkward. ... you've read a line you can use all of C's string handing functions ...
    (comp.lang.c)
  • Re: reading a line through scanf
    ... gyan wrote: ... > I want to read a line with white spaces though scanf. ... Prev by Date: ...
    (comp.lang.c)