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

I used this and it works (+)
Posted by MadPsyentist/Sam 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.
Re: I used this and it works (+)
Posted by ruX 25 Dec 2006 01:07
Yes, you are right

my c++ program recieve WA#6
When i translate it to delphi i recive AC.
Re: I used this and it works (+)
Posted by Slam [Tartu U] 27 Dec 2006 04:25
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++..
Re: I used this and it works (+)
Posted by dibrov.bor 27 Dec 2006 20:14
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
Re: I used this and it works (+)
Posted by Slam [Tartu U] 27 Dec 2006 21:04
obviously, there must be !feof(stdin)