ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1089. Verification with the Dictionary

MadPsyentist/Sam I used this and it works (+) [4] // Problem 1089. Verification with the Dictionary 14 Apr 2003 22:38
fraction of my C/C++ code  , text reading part

...
...
char temp[100000];
int tempsize;
int c;
...
...
tempsize=0;
while ((c=fgetc(stdin))!=EOF) {
 temp[tempsize++]=c;
}
tempsize-=2; // cut the empty line at the end of input
...
...

I got WA
but if I change it to

...
...
char temp[100000];
int tempsize;
int c;
...
...
tempsize=0;
// CHANGEs HERE !!!
while (feof(stdin)) {
 temp[tempsize++]=fgetc(stdin);
}
tempsize-=2; // cut the empty line at the end of input
...
...

I got AC.

I don't know why , but I think it might be useful for others.
Yes, you are right

my c++ program recieve WA#6
When i translate it to delphi i recive AC.
Thanks a lot, with your help I've finally solved this terrible problem:) it's horror to manipulate with special string characters (like eof, eoln) in C++..
useful idea
but on my local compiler "feof (stdin)" always return 0, ever buf is clear, ever not

Edited by author 27.12.2006 20:28
obviously, there must be !feof(stdin)