添加比较

This commit is contained in:
zhuyijun 2021-08-05 23:59:57 +08:00
parent 168b6234e6
commit dc548c0892

30
base/compstr1.cpp Normal file
View File

@ -0,0 +1,30 @@
//
// Created by nicemoe on 2021/8/5.
//
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char word[5] = "?ate";
for (char ch = 'A'; strcmp(word, "Mate"); ch++)
{
word[0] = ch;
cout << word << endl;
}
cout << "After loop ends,word is " << word << endl;
//strcmp中两个字符串相等为0
cout << strcmp("a", "b") << endl;
cout << strcmp("b", "a") << endl;
cout << strcmp("a", "a") << endl;
cout << 0b111 << endl;
string list[3] = {"I", "Love", "You"};
for (const string& str: list)
{
cout << str << "\t";
}
return 0;
}