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:

  1. double backslashes, la "\\hline \\\\" (the backslash escape itself, in tex).
  2. use c++11 raw strings, r"(\hline \\)" (the text enclosed parens inside quotes).

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -