开发者

what is the difference between \c and \\c?

I'm using \c to center a line for terminal report. The report开发者_高级运维 looks good as requested when I see it in linux box (via putty). The intented terminal is using Win1252 (Western) character set as 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". Is there any difference in \\c and \c?

Thank you very much for any help you provide.


If you write this string from C source code, and you want the output to be \c, then you have to escape the escape character \ in your source code.

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

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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜