S
Skysword
Hi there,
I got a problem with this. If I have a fuction like the following
bool valid(int m, int n)
{ if(!isdigit(m)||!isdigit(n))
return false;
else
return true;
}
int main()
{ int a,b;
cin>>a>>b;
cout<<valid(a,b);
system("pause");
return 0;
}
when I input "b 3", the program crashes, it's suppose to print "0",
right? how could this happen? how can I fix it? I want foo to ensure
input for a and b are in a certain range and do not accept letters, of
course
thanks!~
Joseph
I got a problem with this. If I have a fuction like the following
bool valid(int m, int n)
{ if(!isdigit(m)||!isdigit(n))
return false;
else
return true;
}
int main()
{ int a,b;
cin>>a>>b;
cout<<valid(a,b);
system("pause");
return 0;
}
when I input "b 3", the program crashes, it's suppose to print "0",
right? how could this happen? how can I fix it? I want foo to ensure
input for a and b are in a certain range and do not accept letters, of
course
thanks!~
Joseph