#include <iostream>
using namespace std;
int main()
{
char ch[10] = "0";
int count = 0;
cout << "Enter words(to stop ,type the word done): ";
cin >> ch;
while (strcmp(ch,"done")!=0)
{
cin >> ch;
count++;
}
cout << endl << "You entered a total of " << count << " word";
}
uj5u.com熱心網友回復:
strcmp函式是string compare(字串比較)的縮寫,用于比較兩個字串并根據比較結果回傳整數。基本形式為strcmp(str1,str2),若str1=str2,則回傳零;若str1<str2,則回傳負數;若str1>str2,則回傳正數。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/74473.html
標籤:C++ 語言
上一篇:error C2109: subscript requires array or pointer type報錯 怎么辦 求大佬解決
下一篇:字串匹配
