Re: reading a line through scanf
- From: Lawrence Kirby <lknews@xxxxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 10:39:20 +0100
On Thu, 30 Jun 2005 01:30:36 -0400, 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?
This scand for a matching sequence of ' / and n characters so I would be
very surprised if this "works" for what you want opn any system.
The appropriate function for reading a line is fgets(). While scanf() can
be made to do this it is not what it is designed for and is awkward. Once
you've read a line you can use all of C's string handing functions
including sscanf() to decode it.
Lawrence
.
- References:
- reading a line through scanf
- From: gyan
- reading a line through scanf
- Prev by Date: Re: reading a line through scanf
- Next by Date: Re: fast multiple file access
- Previous by thread: Re: reading a line through scanf
- Next by thread: Re: reading a line through scanf
- Index(es):
Relevant Pages
|
|