在我正在創建的程序中搜索潛在錯誤時,我得到了 「[錯誤] ISO C++禁止指針和整數[-fpermissive]之間的比較。」有沒有更好的方式來格式化這個while循環?
錯誤來自我的while循環,其中我打算程序只接受來自用戶的以下輸入。現在,我正在考慮爲這個數組使用一個數組。
我該如何解決這個問題?如果有人有任何更多的細節,我很樂意通過展示我的內容來提供他們(截至最近)。
int main() // While using one of the three functions to make conversions,
// the program will create the table based on following information.
{
char dimension;
double u1, u2;
int starting_value, ending_value, increment, startingUnitDigits,
endingUnitDigits;
cout << "-------------------------------------------------------------------------------------------------";
cout << "Please answer the following questions as they appear.";
cout << "Check spelling, use correct abbreviation for units of measurement, and avoid negative values.";
cout << "-------------------------------------------------------------------------------------------------";
cout << "Enter the dimensions from the following choices: length, mass and time. (i.e.: 'length,' 'Length').";
while (!(dimension == "length" || dimension == "Length" || dimension == "mass" || dimension == "Mass" || dimension == "time" || dimension == "Time"))
{
cout << "----------------------------------------------------------------------------------------------------";
cout << "Error! Input for Dimension, " << dimension << ", was either an invalid choice or typed incorrectly.";
cout << "Please know that this programs accepts length, mass, and time only!";
cout << "----------------------------------------------------------------------------------------------------";
cout << "Enter the dimensions from the following choices: length, mass and time. (i.e.: 'length,' 'Length').";
cin >> dimension;
'焦炭dimension'其1個字符,並要檢查尺寸==「長度」 ..等 –
'尺寸==「長度」'比較了' char'帶有'const char [7]',因此是錯誤信息。 – user0042
@Catholic_Ryanite使用std :: string dimension;而不是char維度;並在循環之前初始化它 –