简体   繁体   English

\\ c和\\\\ c之间有什么区别?

[英]what is the difference between \c and \\c?

I'm using \\c to center a line for terminal report. 我正在使用\\ c来为终端报告居中。 The report looks good as requested when I see it in linux box (via putty). 当我在linux框中看到它时,报告看起来很好(通过putty)。 The intented terminal is using Win1252 (Western) character set as transalation. 意图终端使用Win1252(西方)字符集作为transalation。 But their side, the lines are not aligned to the center. 但是他们这边,线条没有与中心对齐。

Their SRS says, "\\c is used to indicate that the text following the directive up to the end of line should be centered". 他们的SRS说,“\\ c用于表示直到行尾的指令后面的文本应该居中”。 Is there any difference in \\\\c and \\c ? \\\\c\\c有什么区别吗?

Thank you very much for any help you provide. 非常感谢您提供的任何帮助。

如果从C源代码中编写此字符串,并且希望输出为\\c ,则必须在源代码中转义转义字符\\

printf("\\c");    // Will print \c in the output

\\c means you are escaping the "c" character, allowing you to print c \\c means you are escaping the "\\" character, which allows you to print \\c \\ c表示您正在转义“c”字符,允许您打印c \\ c表示您正在转义“\\”字符,这允许您打印\\ c

Escaping a character means that you are making the compiler ignore the character, if it is used for any functions or is reserved within a string. 转义字符意味着您使编译器忽略该字符,如果它用于任何函数或在字符串中保留。

Ex: 例如:

string = "bla bla \c bla \\c"; 

printing string will turn out like this: 打印字符串将如下所示:

"bla bla c bla \c"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM