how to define empty input (cin)

Hi
I want to get numbers from the user till hw press enter
this is my code
1
2
3
4
5
6
while(value!=NULL)
{
        cin>>value;
	if (value!=NULL)
		cout<<value<<" ";
}


but it dosen't work.
what to do ?
closed account (zb0S216C)
What doesn't work?

Wazzak
I want to get out from loop when cin get enter without any other value.

Last edited on
Is it possible ?
You could read in a string and check for the empty string.
It's not working.
That's not enough information for anyone to help you.
probably you should do the loop until the user enter 0 (zero)...probably that's better...
variable can't be = NULL if you do not assign NULL to variable. if you do like this
int variable;
variable will have a value, but you can't know what.

you can do something like this
1
2
3
4
5
int var = 1;
while (var != 0)
{
  cin >> var;
}
Topic archived. No new replies allowed.