Multiple Input Lab3

1 view
Skip to first unread message

Alexis Vanacker

unread,
Mar 4, 2010, 11:12:48 AM3/4/10
to proglang-course-2010
Hello,

We are having some problems with the test suite in lab3: when
interpreting the file good11.cc, our interpreter reads the value 1
(the first) but after, he gets "null" as input value (and hence cannot
apply the expression x=ReadInt() ).
We use a basic BufferedReader in java. Did anyone see this error also?
Or have any ideas on the subject?

Thanks in advance.

Raphaël Vandon

unread,
Mar 4, 2010, 11:46:40 AM3/4/10
to proglang-c...@googlegroups.com
If you create a new buffer each time you meet the readX function, then the problem is here. You should create only one buffer, otherwise the first one eats all the input and then is discarded.

2010/3/4 Alexis Vanacker <alexva...@gmail.com>

Alexis Vanacker

unread,
Mar 4, 2010, 12:17:26 PM3/4/10
to proglang-course-2010
I tried creating a variable in the environment which would hold the
BufferedReader (or Scanner)
and then the readX function accesses it when called... however I still
get the same mistake...

On 4 mar, 17:46, Raphaël Vandon <vand...@gmail.com> wrote:
> If you create a new buffer each time you meet the readX function, then the
> problem is here. You should create only one buffer, otherwise the first one
> eats all the input and then is discarded.
>

> 2010/3/4 Alexis Vanacker <alexvanac...@gmail.com>

Raphaël Vandon

unread,
Mar 4, 2010, 1:02:23 PM3/4/10
to proglang-c...@googlegroups.com
If the error is really coming from the second input, then I don't know. Otherwise it could be that your while does not stop after reading zero, then it will try to read a 21st entry and find a null too.

2010/3/4 Alexis Vanacker <alexva...@gmail.com>
Reply all
Reply to author
Forward
0 new messages