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);
^
Should you not use '\n' instead?And should you not exclude the newline
when trying to read a newline? I feel [^\n] might just be more
appropriate.
> above is working in one program, but in other..what may be the reason?

.



Relevant Pages

  • 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
    ... gyan wrote: ... > I want to read a line with white spaces though scanf. ... Prev by Date: ...
    (comp.lang.c)
  • Re: reading a line through scanf
    ... gyan wrote: ... > I want to read a line with white spaces though scanf. ... Why bother - scanf is not easy to handle. ... Chuck F ...
    (comp.lang.c)
  • Re: scanf problem
    ... because after the first scanf a newline is left ... character in the first input line is a newline. ... Any whitespace in the format string will match any amount of whitespace ...
    (comp.lang.c)
  • Re: Help! Esc button wont exit program
    ... Floating-point numbers on most computers today are binary and ... cannot exactly represent most decimal fractions. ... and if that next scanf is %c it will get only the newline; ...
    (comp.lang.c)