Open
Conversation
meatatt
requested changes
Dec 1, 2016
|
|
||
| $(P | ||
| As we have already been using in the previous chapters, the format specifier $(STRING " %s") reads the data according to the type of the variable. For example, as the type of the following variable is $(C double), the characters at the input would be read as floating point number: | ||
| $(STRING “%s”) 将根据变量的类型读取数据,这和我们在前一章中使用的相同。比如下面这个类型为 $(C double) 的变量会令程序从标准输入读取浮点型的数据: |
Member
There was a problem hiding this comment.
$(STRING “%s”) => $(STRING " %s")
代码中的字符串字面量,是正文中的嵌入内容,不修改
|
|
||
| $(UL | ||
| $(LI $(B The space character): Indicates $(I zero) or more whitespace characters at the input and specifies that all of those characters should be read and ignored.) | ||
| $(LI $(B 空白字符):说明符或输入中的$(I 零)或多个空白字符将被读取并忽略。) |
Member
There was a problem hiding this comment.
错译,应译为:
表示输入中的$(I 零个)或多个空白字符,并指示这些字符应被读取并忽略。
|
|
||
| $(P | ||
| Reading a single line of data from the input has been recommended as $(C strip(readln())) in the $(LINK2 /ders/d.en/strings.html, Strings chapter). Instead of that method, a $(C \n) character at the end of the format string can achieve a similar goal: | ||
| 在 $(LINK2 /ders/d.cn/strings.html, Strings) 一章中,我们曾推荐使用 $(C strip(readln())) 来按行读取输入的数据。除了这种方法,在格式化字符串后添加 $(C \n) 也可以达到同样的目的: |
| write("First name: "); | ||
| string firstName; | ||
| readf(" %s\n", &firstName); // ← \n at the end | ||
| readf(" %s\n", &firstName); // ← 在末尾添加一个 \n |
Member
There was a problem hiding this comment.
此处是输入数据,没有添加意,应译为:
末尾的 \n
与下文(95)呼应
| write("Last name : "); | ||
| string lastName; | ||
| readf(" %s\n", &lastName); // ← \n at the end | ||
| readf(" %s\n", &lastName); // ← 在末尾添加一个 \n |
Member
Author
|
@meatatt 已修正 |
meatatt
approved these changes
Mar 19, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.