请问有谁能告诉我比较两个常数char星的最有效方法吗?
#include <iostream>
#include <string>
int main()
{
const char* value1 = "hello";
const char* value2 = "HELLO";
const char* possibility = NULL;
if(stricmp(value1, value2)==0)
{
std::cout <<"\nThey Match!!!!!" << std::endl;
}
else{std::cout << "\nThey dont match :("<< std::endl;}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我使用了以下标准功能,但我知道它不是最有效的方法吗?
除了stricmp
无法处理NULL,在我的情况下有可能发生.
那么还有其他有助于提升性能的替代方案吗?
提前致谢