我遇到了isdigit问题。我读了文档,但是当我输出数字(9)时,我得到一个0.我不应该得到1吗?isdigit()C++,可能是简单的问题,但卡住了
#include <iostream>
#include <cctype>
#include "Point.h"
int main()
{
std::cout << isdigit(9) << isdigit(1.2) << isdigit('c');
// create <int>i and <double>j Points
Point<int> i(5, 4);
Point<double> *j = new Point<double> (5.2, 3.3);
// display i and j
std::cout << "Point i (5, 4): " << i << '\n';
std::cout << "Point j (5.2, 3.3): " << *j << '\n';
// Note: need to use explicit declaration for classes
Point<int> k;
std::cout << "Enter Point data (e.g. number, enter, number, enter): " << '\n'
<< "If data is valid for point, will print out new point. If not, will not "
<< "print out anything.";
std::cin >> k;
std::cout << k;
delete j;
}
并不意味着要窃取你的答案。我正在关闭Google,并没有看到回复。 – 2010-06-03 23:52:43
'isdigit',而不是'isDigit';) – tzaman 2010-06-03 23:53:16
那么,如何验证userInput,因为我需要单引号在parantheses? – Crystal 2010-06-03 23:54:18