输入; N.推回(输入); } 系统(“暂停”); 返回0; },c++,filereader,C++,Filereader" /> 输入; N.推回(输入); } 系统(“暂停”); 返回0; },c++,filereader,C++,Filereader" />

未完全读取文本文件 我试图从C++中的文本文件中读取一些整数。奇怪的是,它只读取13个数字,而我的文件包含25个数字。我搜索了,但没有找到任何东西,有人建议添加ios::binary,但不起作用。 为什么?? 下面是这部分代码 #include <iostream> #include <vector> #include <cmath> #include <fstream> using namespace std; int main() { ifstream myfile; myfile.open("Nvector.txt"); vector<int> N; for(int j=0; j<25; j++) { int input; myfile>> input; N.push_back (input); } system("PAUSE"); return 0; } #包括 #包括 #包括 #包括 使用名称空间std; int main() { ifstreammyfile; myfile.open(“Nvector.txt”); 向量N; 对于(int j=0;j>输入; N.推回(输入); } 系统(“暂停”); 返回0; }

未完全读取文本文件 我试图从C++中的文本文件中读取一些整数。奇怪的是,它只读取13个数字,而我的文件包含25个数字。我搜索了,但没有找到任何东西,有人建议添加ios::binary,但不起作用。 为什么?? 下面是这部分代码 #include <iostream> #include <vector> #include <cmath> #include <fstream> using namespace std; int main() { ifstream myfile; myfile.open("Nvector.txt"); vector<int> N; for(int j=0; j<25; j++) { int input; myfile>> input; N.push_back (input); } system("PAUSE"); return 0; } #包括 #包括 #包括 #包括 使用名称空间std; int main() { ifstreammyfile; myfile.open(“Nvector.txt”); 向量N; 对于(int j=0;j>输入; N.推回(输入); } 系统(“暂停”); 返回0; },c++,filereader,C++,Filereader,您可能需要检查正在读取的文本文件,可能会有特殊的行尾字符导致整数从向量中串联/删除,也可能会有与向量相关的问题该文件如何?您应该检查myfile>>输入的结果;如:如果(!(myfile>>input){std::cout>>“Error”>>std::endl;}请用一个或抱歉的拼写错误回答您的问题:std::cout@πάνταῥεῖ 我发现问题不在于文件,可能与向量有关。

您可能需要检查正在读取的文本文件,可能会有特殊的行尾字符导致整数从向量中串联/删除,也可能会有与向量相关的问题

该文件如何?您应该检查
myfile>>输入的结果;
如:
如果(!(myfile>>input){std::cout>>“Error”>>std::endl;}
请用一个或抱歉的拼写错误回答您的问题:
std::cout@πάνταῥεῖ 我发现问题不在于文件,可能与向量有关。