YourMomsASmurph
January 10th, 2010, 01:37 AM
Hokay so this is a seemingly basic question. Im attempting to limit a persons input so that if they put in a string instead of number, and error occurs, the program won't end.
Was using python before and was wondering how to convert it into a C++ code.
This is what i have so far.
while (x==0) {
try {
//Enter some cin code here
x++ //Assuming that this code wouldnt work UNLESS the cin didn't result in error.
}
except ValueError // The python code that would go here. (From my limited experience.)
Also have 2 more questions, 1 of which deals with user input again.
1:What do i do if I want to limit user input to a specific # of characters? (Could google this one BUT I'm already making a thread so yea)
2:How would I be able to extract 2 numbers from one input.
cin >>xy // entered in the form x,y
and i want to extract the x and the y seperately.
Was using python before and was wondering how to convert it into a C++ code.
This is what i have so far.
while (x==0) {
try {
//Enter some cin code here
x++ //Assuming that this code wouldnt work UNLESS the cin didn't result in error.
}
except ValueError // The python code that would go here. (From my limited experience.)
Also have 2 more questions, 1 of which deals with user input again.
1:What do i do if I want to limit user input to a specific # of characters? (Could google this one BUT I'm already making a thread so yea)
2:How would I be able to extract 2 numbers from one input.
cin >>xy // entered in the form x,y
and i want to extract the x and the y seperately.