我遇到了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