It gets really kind of trippy if you wanna output a backslash, \ you can't just use the backslash, \\ you need to use backslash backslash because otherwise a single backslash is confused with the so called escape character.
如果你想输出一个反斜杠,估计又得迷糊了,实际上,你不能直接用,而是要,否则一个\可能会被误认为,是转义字符。
And just intuitively, when might you need to put a backslash in front of a double quote given the examples we've seen thus far?
凭直觉来看,迄今为止,你们什么时候,会用到\“呢?,举个例子?
0 And we'll also see backslash 0 which is actually the special character that's used at the end of a string to say no more string after this point in memory.
还有0,用于存储器中字符串末尾,表示在此之后就,没有字符了。
n If you want a literal percent, it's %% and then backslash n.
如果你想要一个百分比常量,就用%%,然后,反斜杠。
So you have what are called escape characters like backslash N that is the shorthand notation of telling the computer put a new line character here.
幸亏我们有一些类似反斜杠n的转义字符,这只是一种简化方式,用来告知电脑要在这新添一行。
For some reason I had this backslash N, a close quote, parenthesis, semicolon, close curly brace.
由于某些必要原因,我们还得加上\n,后引号,圆括号,分号,后大括号。
If n is greater than zero, I decided I would say, "You picked a positive number, backslash n," so put the cursor on the next line, else if n was not less than zero, I say, "You picked a negative number, backslash n."
如果n比0大,我就决定来说:,“你选择了一个整数,反斜杠n“,所以你把光标,放在下一行,另外如果n不小于0,我说:,“你选择一个负数,反斜杠n“
You can certainly hit Enter but as we saw-- seen that very quickly makes a mess of your code and such and so backslash N is new line.
你也可以敲回车键-,但是会让你的代码看起来乱七八糟,反斜杠n就是换行符。
Let me go ahead and call print F. I'm going to say A equals A and then I need a percent D, backslash, comma A; so this is a little bit of -- more syntax than would be nice, %d but I'm just saying, literally, A equals percent D, and I'm plugging in the value of A for percent D.
我们继续调用printf,我说明A等于,然后我需要%d,反斜杠n,逗号;,所以这个有点--偏向逻辑的,而不偏向美观的,但是我刚说了,字面上,A等于,我用%d插入了A的值。
应用推荐