How do I know when the input has ended?
I know this might sound stupid, but how am I supposed to know when I've finished inputting numbers? I don't see anything saying what A is equal to, so how do I know?
Re: How do I know when the input has ended?
read FAQ.
for C++:
double n;
while (scanf("%lf", &n) != EOF)
{
...
}
Re: How do I know when the input has ended?
Послано
dims 7 июн 2012 20:58
I have the same question.
What about Java? there's no answer to that in FAQ.
Re: How do I know when the input has ended?
Послано
Noob 7 июн 2012 22:12
Just catch Exception :D
Re: How do I know when the input has ended?
Послано
Haji 24 янв 2013 12:21
How to make the EOF? I mean how does it know when the user stopped inputting?
Re: How do I know when the input has ended?
As for C#, you can use (as an example):
string[] inputValues = Console.In.ReadToEnd().Split(new char[] {' ', '\t', '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries);
Re: How do I know when the input has ended?
Послано
Your_Y 2 фев 2013 14:58
///
Edited by author 02.02.2013 14:58
Edited by author 02.02.2013 14:58
Re: How do I know when the input has ended?
Послано
Faruk 3 дек 2014 10:40
I have same prblm in c.
Re: How do I know when the input has ended?
I have the same problem with Go. Can someone help me.
Re: How do I know when the input has ended?
Послано
Romina 24 дек 2014 23:57
For windows command prompt CTRL Z would be interpreted as EOF
Re: How do I know when the input has ended?
For linux terminal Ctrl + d is the EOF character.
Re: How do I know when the input has ended?
You'll know the input has ended when one of the following happens, depending on the method you choose to read in the first place :
InputStreamReader in;
while(in.read() != -1)
BufferedReader in;
while((line = in.readLine()) != null)
Re: How do I know when the input has ended?
You'll know the input has ended when one of the following happens, depending on the method you choose to read in the first place :
InputStreamReader in;
while(in.read() != -1)
BufferedReader in;
while((line = in.readLine()) != null)