Friday, April 9, 2010

how to chk if a no. is integer or not.

Source :

using namespace std;
int main(){
 double num1;
 if(static_cast(num1) == num1)//casts num1 to type int
  cout<<"Not Integer"<
  return 0;

Another method is
char *test = "asdf1234";
int i;
for (i = 0; i < strlen (test); i++)
if (isdigit (test[i]))
(stdout, "test[%d] is a digit!\n", i);

No comments:

Post a Comment