Question: Missing a chunk of information while reading from a file.

Hello All,

I have a function named showcontent. I have around 5,000 lines that I am reading in from a file. When I display the content it's formatting correctly only that I am missing a huge chunk of information. It's only displaying data from V to Z, and I am not sure where A to Z went. Is there a size limit as to how much information can be displayed on the screen to the end user ?? or do I have a syntax error somewhere....?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>
#include<fstream>
#include<vector>
#include<string>

using namespace std;

int main()
{
    const int ListSize=10000;
    int choice;// to hold user input option
    int index;// to store and access array and vector values
    string schoolSearch; // to hold user string to search
    fstream dataFile;// File Stream Object
    vector<string>collegeList;

// Function Prototypes
    bool openFileIn(fstream&,string);
    void showcontents(fstream&);
    if (openFileIn(dataFile,"Colleges.txt"))
    {
        cout<<"Reading File Contents!";
        showcontents(dataFile);
        dataFile.close();

        for(index=0; index<ListSize; index++)
            getline(dataFile,collegeList[index]);
    }
    else if(!dataFile)
    {
        cout<<" Error Opening file.";
    }




return 0;
}
bool openFileIn(fstream&file,string name ) // function definition
{
file.open("Colleges.txt",ios::in);
              if (file.fail())
                  return false;
                         else
                             return true;
}

void showcontents(fstream&file)
{
    string line;
    while(file)
    {
    getline(file,line);
    cout<<line<<endl;
    }
  }
Last edited on
The amount of information your console can show is limited. It's not that the information is missing, it's that much of it has "scrolled off" of the console buffer.

Try writing to another file (rather than, or in addition to, the console) and inspecting its contents to verify that you aren't missing information.
Yes, i thought that might be the issue that there might be a limit.. Thank you so much I have been staring at the screen for hours! :(

Now I can be certain that the information is not missing, I will be testing by writing it to another file as mentioned.

Thanks!
Topic archived. No new replies allowed.