본문 바로가기
c++ 기초

string과 string 이어 붙이기

by BitsrimAcrux 2025. 1. 25.
#include <string>
#include <iostream>

using namespace std;

int main() {
    string str = "Hello";
    string str1 = " World!";
    
    str += str1;  // str에 str1을 이어 붙임
    cout << str << "\n";  // 출력: "Hello World!"
    
    return 0;
}
728x90

'c++ 기초' 카테고리의 다른 글

vector 배열 생성  (0) 2025.01.26
to_string, stoi  (0) 2025.01.25
string 크기 설정  (0) 2025.01.25
string 길이 구하기  (0) 2025.01.25
#include <string>  (0) 2025.01.21