I am trying to output a string to a file in the form

cout << "\" << (an expression) << "\";

however, my compiler won't accept it, i can't get it to output that without there being a space between the slash and the close bracket i.e. "\ ".

There is probably a simple method to get past this, but any help would be appreciated.

Regards
Kevin

Try:

cout << "\\" << (an expression) << "\\";

\ is an escape sequence, so you must treat it with extra care.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.