correct way to get char input


First I use this, the compiler show no error but the cmd stop working.
1
2
char * binput;
cin>>binput;


Therefore I change to this one, also from tutorial.
1
2
char binput[30];
cin>>binput;

This one work but I have to put some size of array there.
Lets say if I write char binput[2], how many character can I input?
And what is wrong with the first one? which one is the better way to use?
or either one is not good?
Thank you.
the cmd stop working.
What memory binput point to? You are trying to write in some random memory, causing crash.

Lets say if I write char binput[2], how many character can I input?
One. Another one is reserved for null terminator.

And what is wrong with the first one? which one is the better way to use?
or either one is not good?
This is better:
1
2
std::string binput;
std::cin >> binput;
Topic archived. No new replies allowed.