Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exercise 3.2的代码可能有错误 #16

Closed
ghost opened this issue Feb 14, 2015 · 2 comments
Closed

exercise 3.2的代码可能有错误 #16

ghost opened this issue Feb 14, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 14, 2015

因为题目是说输出text第一段,参见中文版P98(英文版P110)那段代码的注释是说一次输出text的每一行直至遇到第一个空白行为止
您的代码我没有弄错的话,应该是只将第一行字母变成大写,而不是题意中的将第一段变成大写(书中的一段应该指的是直到遇到第一个空白行之前的都算第一段)

我觉得正确的代码应该如下:
int main()
{
string tempStr;
vector text;
while (getline(cin, tempStr))
text.push_back(tempStr);
vector::iterator it;
for (auto it = text.begin(); it != text.end() && !(*it).empty(); ++it)
for (auto &c : *it)
c = toupper(c);

for (auto it = text.begin(); it != text.end(); ++it)
    cout << *it << endl;
    return 0;

}
如果弄错了,抱歉哈!
还有发issue,和pull request是不是没区别,我将你的这个project fork到我自己账户下,那么我在pull request里写这个问题,是不是您也能看到呢?
还有一个小问题,如果将我贴的代码变成代码片,我看我贴上的代码感觉就是纯汉字格式那样(不知道您懂我描述的意思吗)

@pezy pezy closed this as completed in b506409 Feb 14, 2015
@pezy
Copy link
Owner

pezy commented Feb 14, 2015

@cxs944745612 感谢你指出Bug,这块的确错会题意了。

issue 与 pull request 是有区别的,可以有空查看一下: https://help.github.com/ 跟着教程走一走。

另外也贴一份中文的:http://www.worldhello.net/gotgithub/04-work-with-others/010-fork-and-pull.html


你说的贴的代码变成了代码片,是因为 Markdown 语法的缘故,可以参考这里:https://help.github.com/articles/markdown-basics/

@ghost
Copy link
Author

ghost commented Feb 15, 2015

非常感谢,我去看看

sarvex pushed a commit to sarvex/CppPrimer that referenced this issue Apr 27, 2023
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

No branches or pull requests

1 participant