getline回收回车
时间: 2023-10-22 14:30:29 浏览: 104
C++中getline()的用法详解
5星 · 资源好评率100%
getline函数在读取字符串时,默认会将回车符('\n')作为字符串的结束符,并从输入流中提取出来丢弃。这意味着getline函数并不会将回车符包含在读取的字符串中。如果你希望在读取字符串时保留回车符,可以在getline函数的第二个参数中指定一个不同的结束符,例如指定回车符为结束符。但需要注意的是,在这种情况下,getline函数会将回车符包含在读取的字符串中。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [《C++面向对象程序设计》✍千处细节、万字总结(建议收藏)](https://blog.csdn.net/weixin_44368437/article/details/117563488)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [面临复杂问题时的几个高级工具:它山之石,可以攻玉](https://blog.csdn.net/kimmking/article/details/108728961)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文