如何做是>> std :: skipws>>通过数组的多个索引?
假设您有std :: array< int,size>一个
,您将a
的每个元素保存到一个由空间隔开的行中的文件中。然后,您想使用std:istream&阅读它们。 IS
via:
is >> std::skipws >> a[0] >> a[1] >> a[2] >> ... >> a[SIZE-1];
如何为大小
的任何值写入此操作。即使还有其他简单的方法可以做到这一点,我很好奇通过这种特定方法完成的工作。
Let's say you have std::array<int, SIZE> a
, and you have saved each element of a
into a file in one line separated by a space. Then you want to read them with a std:istream& is
via:
is >> std::skipws >> a[0] >> a[1] >> a[2] >> ... >> a[SIZE-1];
How to write this generically for any value of SIZE
. Even though there are other easy ways of doing this, I'm curious how it is done with this particular method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有用于重复操作的控制结构可变数量:循环。
例如:
There are control structures for repeating an operation a variable number of times: loops.
For example: