c++ - Print on the screen the symbol \ as text -
this question has answer here:
i want following printout appear in screen when run code:
\begin{tabular} \hline \\ for that, using following command on code:
std::cout<<"\begin{tabular}<< std::endl; std::cout<<"\hline \\"<< std::endl; and i'm getting following compiler message (regarding second line of code):
unknown escape sequence: '\h' and following incomplete printout:
egin{tabular} hline\ where in first 1 "\b" missing , first , last \ missing second sentence.
the question is: know how can print \ symbol text, such printed , not interpreted command, etc?
the backslash forms escape sequences in c++. have 2 options:
- double backslashes, la
"\\hline \\\\"(the backslash escape itself, in tex). - use c++11 raw strings,
r"(\hline \\)"(the text enclosed parens inside quotes).
Comments
Post a Comment