简体   繁体   中英

Not Fully read from the text file

I am trying to read some integer numbers from a text file in C++. It is weird problem that it reads only 13 numbers , but my file contains 25 numbers . I searched but not found any thing , someone suggested to add ios::binary , but not working. Why ?? here is this part of code.

#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;

}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM