In C ++ string type of usage-related

A, string type

  1. Header file: include
  2. With scanf, use the fetch address character &
  3. If you want to use the compare function to compare
  4. Use scanf may occur mistakes questions in the test point, you can use cin
string s1, s2;
s1.compare(s2) == 0;
如果相等就是返回0

Two, char array

  1. Header file: include
  2. Using the comparison function strcmp ();
  3. In scanf, fetch address character may not be used.
char s1[12], s1[13];
strcmp(s1, s2) == 0;
(s1 > s2) > 0;
(s1 < s2) < 0;

Guess you like

Origin www.cnblogs.com/tsruixi/p/12313543.html