Hi All,
I'm brand new to C++ and writing a program which asks for user input to open a text file then displays the text file using specific characters which parse the file. The files that I need to open are too large to display the entire contents and the top of the file is getting cut off. Does anyone have any ideas on how to display the entire contents of the file? THANKS!!
Here's my code:

#include<iostream>
#include<fstream>
#include<string>

using namespace std;

int main()
{
    string filename;
    cout << "Enter location and name of .txt file:  ";
    getline ( cin, filename);
    ifstream in1 (filename.c_str() );
    string str1, line1;
    
    while(getline(in1, line1))
    str1 += line1;
 
    string toFind = "#";
    string replaceWith = "\n";
    string toFind2 = "[";
    string replaceWith2 = "\n";
    string toFind3 = "{";
    string replaceWith3 = "\n";
    string toFind4 = "!!!!";
    string replaceWith4 = "\n";
         
     int pos;
     while ((pos = str1.find(toFind)) != string::npos)
          str1.replace(pos,toFind.size(),replaceWith);
     while ((pos = str1.find(toFind2)) != string::npos)
          str1.replace(pos,toFind2.size(),replaceWith2);
     while ((pos = str1.find(toFind3)) != string::npos)
          str1.replace(pos,toFind3.size(),replaceWith3);
     while ((pos = str1.find(toFind4)) != string::npos)
          str1.replace(pos,toFind4.size(),replaceWith4);

     cout << str1 << endl; 

     cin.get();
     cin.get();
     return 0;
}

You could just display a certain number of lines and when the user presses the down arrow key it displays more text

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.