본문 바로가기

c++

c++11 원시 문자열 리터럴

c#에는 문자열에 @를 붙여주면 문자열 내의 이스케이프 문자를 그대로 인식한다

string dir = @"C:\hello\world";
Console.WriteLine(dir);
//출력 : C:\hello\world

 

c++에서는 이스케이프가 포함된 문자열을 표현하기 위해서 아래와 같이 R"()"을 사용한다

string dir = R"(C:\hello\world)"
std::cout << dir << endl;
//출력 : C:\hello\world

 

MSDN : https://docs.microsoft.com/ko-kr/cpp/cpp/string-and-character-literals-cpp?view=msvc-160

 

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

c++ cout 출력 소수점 정밀도 setprecision, fixed  (0) 2021.10.10