#include <strings.h>
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
string s = "test";
if(strcasecmp(s, "TEST"))
cout << "equals"<< endl;
return 0;
}
幫助需要就如何使用strcasecmp,當我試圖編譯,編譯器保持顯示錯誤消息strcasecmp。無法解決的錯誤消息
error: cannot convert ‘std::string {aka std::basic_string}’ to ‘const char*’ for argument ‘1’ to ‘int strcasecmp(const char*, const char*)
嘗試用'strcasecmp(s.c_str(), 「TEST」)' – max66
見http://stackoverflow.com/questions/11635/case-insensitive-string -comparison-in-c –