// 文字列が等しいとき true を返す
bool StrComp(const string s1, const string s2)
{ unsigned len,i;
len = s1.size();
if (len!=s2.size()) return false;
for(i=0; i<len; i++)
{ if (ciChar(s1.at(i),s2.at(i))) return false;
}
return true;
}
int main()
{ string s1,s2;
s1= "abc";
s2= "ABC";
if (StrComp(s1,s2)) printf("%s == %s\n",s1.c_str(),s2.c_str());
else printf("%s != %s\n",s1.c_str(),s2.c_str());
s2= "Abc";
if (StrComp(s1,s2)) printf("%s == %s\n",s1.c_str(),s2.c_str());
else printf("%s != %s\n",s1.c_str(),s2.c_str());
return 0;
}
|