"C++ 문자열"의 두 판 사이의 차이

 
18번째 줄: 18번째 줄:
int main() {
int main() {
     string s = "foo";
     string s = "foo";
     cout << "s[0]=" << s[0] << endl;
     cout << "s[0]=" << s[0] << ", " << (0+s[0]) << endl;
     cout << "s[1]=" << s[1] << endl;
     cout << "s[1]=" << s[1] << ", " << (0+s[1]) << endl;
     cout << "s[2]=" << s[2] << endl;
     cout << "s[2]=" << s[2] << ", " << (0+s[2]) << endl;
     cout << "s[3]=" << s[3] << endl;
     cout << "s[3]=" << s[3] << ", " << (0+s[3]) << endl;
     cout << "s[4]=" << s[4] << endl;
     cout << "s[4]=" << s[4] << ", " << (0+s[4]) << endl;
    cout << "s[5]=" << s[5] << endl;
     cout << "s[5]=" << s[5] << ", " << (0+s[5]) << endl;
     cout << "s[6]=" << s[6] << endl;
    cout << "done..." << endl;
}
}
</syntaxhighlight>
</syntaxhighlight>

2024년 1월 15일 (월) 20:00 기준 최신판

1 개요[ | ]

C++ string
C++ 문자열
#include <iostream>
using namespace std;

int main() {
    string s = "foo";
    cout << s.length(); // 3
}
#include <iostream>
using namespace std;

int main() {
    string s = "foo";
    cout << "s[0]=" << s[0] << ", " << (0+s[0]) << endl;
    cout << "s[1]=" << s[1] << ", " << (0+s[1]) << endl;
    cout << "s[2]=" << s[2] << ", " << (0+s[2]) << endl;
    cout << "s[3]=" << s[3] << ", " << (0+s[3]) << endl;
    cout << "s[4]=" << s[4] << ", " << (0+s[4]) << endl;
    cout << "s[5]=" << s[5] << ", " << (0+s[5]) << endl;
}

2 멤버 함수[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}