Mail Archives: djgpp/1999/04/05/17:23:28
Ville Kanerva wrote:
>> ...
>> scanf ("%d", &z);
>>
>> printf ("Text:\n");
>>
>> for (i=0;i<z;++i)
>>
>> {
>>
>> fflush(stdin); /* i quess here's your problem */
>>
>> gets(text[i]);
>>
>> l[i]=strlen(text[i]);
>>
>> }
>> ...
>> When I compile it with DJGPP and it should read n(z=n) Lines it only
>> reads n-1 lines. But when I compile it
>> with TurboC it runs correctly. Does someone know where there is a bug?
>
> As i recall, you can't fflush _stdin_ stream, only _stdout_ stream. This
> may cause your problem and irregularities between those two compilers you
> used.
>
No, that can't be the problem, when I leave out the fflush(stdin), it's
still wrong.
But when I replace the gets(text[i]) by scanf(text[i]) it runs
correctly. But with
scanf you can only read words but no sentences(several words with
blanks). Can someone help?
Greetings,
David
- Raw text -