Skip to content

Conversation

@IceNature
Copy link
Member

No description provided.


$(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) 的变量会令程序从标准输入读取浮点型的数据:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$(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 零)或多个空白字符将被读取并忽略。)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

错译,应译为:
表示输入中的$(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) 也可以达到同样的目的:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

章节名同正文处理
Strings => 字符串

write("First name: ");
string firstName;
readf(" %s\n", &firstName); //\n at the end
readf(" %s\n", &firstName); //在末尾添加一个 \n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处是输入数据,没有添加意,应译为:
末尾的 \n
与下文(95)呼应

write("Last name : ");
string lastName;
readf(" %s\n", &lastName); //\n at the end
readf(" %s\n", &lastName); //在末尾添加一个 \n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@IceNature
Copy link
Member Author

@meatatt 已修正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants