如何显示字符串中的\ t字符? [英] how can I display the characters \t in a string?
本文介绍了如何显示字符串中的\ t字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
整个晚上, 将"\ t"显示为文字值而不是文字格式的正确按键顺序是什么?
Evening all, What would be the correct key sequence to display "\t" as a literal value, and not a text format?
我的代码在下面...
My code is below...
谢谢.
main()
{
int c;
while ((c = getchar()) != EOF) {
if (c == ' ')
c = "\t";
putchar(c);
}
}
为了澄清,我不想使用制表符的字符串,而是显示字符\ t.
So to clarify, I do not want to have a tabbed string, but instead display the characters \t.
推荐答案
您可以使用另一个反斜杠("\\t"
)来转义反斜杠.
You can escape a backslash with another backslash, i.e. "\\t"
.
顺便说一句,您试图将一个字符串(即多个字符)分配给int
.这没有道理!
Incidentally, you're trying to assign a string (i.e. more than one character) to an int
. This doesn't make sense!
这篇关于如何显示字符串中的\ t字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文