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?
Posted by
dims 7 Jun 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?
Posted by
Noob 7 Jun 2012 22:12
Just catch Exception :D
Re: How do I know when the input has ended?
Posted by
Haji 24 Jan 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?
Posted by
Your_Y 2 Feb 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?
Posted by
Faruk 3 Dec 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?
Posted by
Romina 24 Dec 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)