C++读取文件直到空间
有没有办法从文件中读取数据直到空格?我有一个文件
John J. Doe
,我想读取该文件并将 John
放入 1 个变量中,将 J.
放入另一个变量中,然后 < code>Doe 在最终变量中。我该如何使用 ifstream 来做到这一点?
Is there a way I can read data from a file until a space? I have a file
John J. Doe
and I want to read the file and put John
in 1 variable, J.
in another variable and Doe
in a final variable. How do I do this with ifstream?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需将值读入 std::string 变量,这将自动对其进行标记。
You can just read the values into std::string variables, this will automatically tokenize it.
这是您的文件名还是文件内容?我认为它是文件内容。
Is this your file name or file content? I assume it's file content.