ok.. ill try if it works.
coz, what im trying to do, is to store the pin(which is 1234) in a string first.. then get the user input and check if it doesnt contain any non numeric characters.. after that, ill store that string into an integer array..
I guess you mean all characters other than 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 when you say: any non-numeric character.
Why not just get your number like this:
cout << "Enter a number: ";
if( !(cin >> num) )
// Reading a number failed, most likely due the fact the user
// didn't enter a valid number.
Put your code to handle such a situation here
or use a stringstream:
char cnum = "1234";
ss << cnum;
if( !(ss >> inum) )
// Again: extracting the number failed
// Most likely due the fact that you're trying to read
// something else than a number.
You need to include the sstream header in order to make the above snippet compile, you can do this by adding the following include directive to your program: #include <sstream> .