string str = "abc";
if(str[0] == 'a') cout << "single" << endl;
else cout << "not equal";
if(str == "abc") cout << "double";
else cout << "not equal";
* 결과
single
double
Process finished with exit code 0
문자 비교시에는 싱글쿼를 이용하고, 문자열 비교시 더블쿼터 이용한다.
'프로그래밍 > C++' 카테고리의 다른 글
char -> int 변환 (0) | 2017.10.24 |
---|---|
c++ string ,int 변환 (0) | 2017.10.24 |
댓글