Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //字串比較
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string s1="this is s1",s2="this is s2";
- char c3[]="this is s1";
- if(s1==s2)
- cout<<"s1==s2\n";
- else
- cout<<"s1!=s2\n";
- if(s1==c3)
- cout<<"s1==c3\n";
- else
- cout<<"s1!=c3\n";
- if(s1.compare(s2)==0)
- cout<<"s1==s2\n";
- else
- cout<<"s1!=s2\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment