I want to take the string tokens and test if they are integers. If not, an exception should be thrown. According to isdigit - C++ Reference , isdigit should return 0 if it is not a digit. But it is returning 0 for anything I input. Why is this? The code snippet is below.
Code:BinaryTree BinaryTree::setTree(char* str) { char* pStr = strtok(str, "()"); BinaryTree result; while(pStr != NULL) { int token = atoi(pStr); if(isdigit(token) == 0) { std::cout<<pStr<<" is nTree"<<std::endl; std::cout<<token<<" is not an int."<<std::endl; throw InvalidInputException(); }