English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

if i have something like this

int x=6;
cin>>x;
@ run time i pressed enter instead of typing a value

is x by now NULL -i mean it should be
otherwise i think it's keeping you in the input mode

2006-11-14 08:01:05 · 3 answers · asked by Rami 5 in Computers & Internet Programming & Design

3 answers

cin>> brings up a prompt that requires your input. Anything you type into the cin>> will replace what already exists in a variable. For example:

int x=6; assigns 6 to the variable x.
cin>>x; means you are requesting the issue of a new variable to x from the end user.

When you get the prompt to enter a value and you simply hit the return (ENTER) key, you are placing a null value into x and the 6 you had previously entered in int x=6; is now gone.

If you want to print out the number 6, use:

print (x); or printf (x);

2006-11-14 08:20:31 · answer #1 · answered by daniel eagles 1 · 1 0

I think if you hit enter it will go to null because that is setting the x to the entered value, which is nothing. But it isn't staying in the prompt mode because you hit enter.

2006-11-14 16:11:37 · answer #2 · answered by scott p 3 · 0 0

usually x will stay null or the garabage in the memory space and you should stay at the prompt until you enter a value

2006-11-14 16:16:14 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers