Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 C++ 新手。所以我真的需要一些帮助。我只有一个 .txt 文件。第一行是行数和列数,接下来是 mxn 浮点值。每行之间都有一个空行。我的目标是读取数据并存储它们。我怎么能用 C++ 做到这一点?
fopen 打开文件,然后可以通过 fscanf 逐个令牌读取。最后调用 fclose 关闭文件。
这些函数源自 C,但它们也是 C++ 的一部分......
或者使用来自 STL 的 IO 模板,例如 ifstream 类。