amannigam
amannigam

Reputation: 29

How Do I Create Raw String in Visual C++?

In C#, I can easily use @"path" to get path that is acceptable to System.IO functions but in C++.NET I am stuck as my path is like "C:\roam..." so it processes "\r" and removes it. So I am not able to get an acceptable path format. Please help.

Upvotes: 0

Views: 381

Answers (2)

Joachim Isaksson
Joachim Isaksson

Reputation: 180997

You'll need to use \\ to write a backslash in a C++ character constant, that is "C:\\roam".

Upvotes: 1

hmjd
hmjd

Reputation: 122001

You need to escape the backslash character:

std::string path("C:\\roam");

Upvotes: 1

Related Questions