添加比较
This commit is contained in:
parent
168b6234e6
commit
dc548c0892
30
base/compstr1.cpp
Normal file
30
base/compstr1.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user