Re: reading a line through scanf
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 06:31:10 GMT
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?
#define LENGTH 20
#define str(x) # x
#define xstr(x) str(x)
int rc;
char array[LENGTH + 1];
rc = scanf("%" xstr(LENGTH) "[^\n]%*[^\n]", array);
if (!feof(stdin)) {
getchar();
}
if (rc == 0) {
*array = '\0';
}
/* rc will be either 1, 0, or EOF */
--
pete
.
- Follow-Ups:
- Re: reading a line through scanf
- From: Suman
- Re: reading a line through scanf
- References:
- reading a line through scanf
- From: gyan
- reading a line through scanf
- Prev by Date: Re: how to let gcc warn me when I use = in conditions
- Next by Date: Re: reading a line through scanf
- Previous by thread: Re: reading a line through scanf
- Next by thread: Re: reading a line through scanf
- Index(es):
Relevant Pages
|