Oct 8, 2015 at 8:25pm UTC
It waits for you to input the integer. Don't forget to press enter.
Last edited on Oct 8, 2015 at 8:25pm UTC
Oct 8, 2015 at 8:28pm UTC
The reason it does not work with a char is because the char is used to read characters. Take a look at line 1, it is an int (integer) and will take integer numbers not char (characters).
Oct 8, 2015 at 8:34pm UTC
Yes I did , I pressed enter. , still it stalls
Oct 8, 2015 at 8:35pm UTC
Just do what chicofeo explained
Oct 8, 2015 at 8:36pm UTC
i know I changed the type to char , and then it worked for a while, but now neither type works
Oct 8, 2015 at 8:37pm UTC
Could you post your new code with the type char, as well as tell us what you input using that code and what the output was.
Oct 8, 2015 at 8:44pm UTC
<code>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
char aInt;
cout << "enter a number:";
cin >> aInt;
cout << "you entered:" << aInt;
cin.get();
return 0;
}
</code>
I entered a character or integer with char first, but now that doesn't work either :
output: enter a number:Press any key to continue....
same with int except i used integers. I think char worked first , but i'm not sure anymore now.
thanks!
Oct 8, 2015 at 8:49pm UTC
I mean. I'm not sure what your problem is here, it works perfectly fine. char is short for character, meaning one character. If you enter the number 55. It will output only 5, because char only holds one character. If you input "My name is" it will output only "M".
What exactly is it that you think is not working correctly?
Oct 8, 2015 at 8:59pm UTC
Last edited on Oct 8, 2015 at 8:59pm UTC
Oct 8, 2015 at 9:00pm UTC
i'm not seeing :
enter a number: 4 you entered 4 (or such)
and a green 'task running' indicator in the bottom right just keeps going.
Thanks again !
Oct 8, 2015 at 9:08pm UTC
are you using a command prompt? Maybe it's a netbeans problem ?
Oct 8, 2015 at 9:08pm UTC
and I don't know how to take a screenshot ?
Oct 8, 2015 at 9:16pm UTC
You can simply google how to take a screenshot and you'll get a billion answers.
Can you tell us what the output is when you enter "Mom"?