본문 바로가기

공부/프로그래밍

C++ .size() 써보기

#include  <iostream>
#include  <string>

using namespace std;
int main()
{
string name = "Robert Taylor";
int size = name.size();
cout << "Name is "<<name<<endl;
cout << "Length of his name is "<<size;
cin >> size;

return 0;
}

스트링의 길이를 계산해주는 함수이다.

728x90