Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the C++ equivalent of the C# @ symbol prefixing strings?

Tags:

What is the C++ equivalent of the C# @ symbol prefixing strings? For escaping symbols automatically?

Example: var howManySlashesAreThereIn = @"\\\\\\";

like image 608
Jake Avatar asked May 09 '12 04:05

Jake


People also ask

What is equivalent to classes in C?

There is nothing equivalent to classes . Its a totally different paradigm. You can use structures in C. Have to code accordingly to make structures do the job.

What is the C equivalent of CIN?

Standard Input Stream (cin) in C++ It corresponds to the C stream stdin. The standard input stream is a source of characters determined by the environment. It is generally assumed to be input from an external source, such as the keyboard or a file.

What is the equivalent of new in C?

There's no new / delete expression in C. The closest equivalent are the malloc and free functions, if you ignore the constructors/destructors and type safety.

What does &= mean in C?

It means to perform a bitwise operation with the values on the left and right-hand side, and then assign the result to the variable on the left, so a bit of a short form.


1 Answers

In C++11, you can use raw string literals:

std::string s = R"(This\is\a\raw\string\literal)";  std::string s = R"*(This \one contains \a )", which would normally end the string)*"; 

Here's the C++11 FAQ word on it, and a reference.

like image 179
chris Avatar answered Nov 24 '22 07:11

chris