I have one error in my code
Error 1 fatal error C1075: end of file found before the left brace '{' at line 50

The program is suppose to ask the user for a filename, read and display the file. Then show 24 lines per screen. I thought I checked all my brackets, but 1 error remains. Any guidance would be greatly appreciated.

#include <iostream>
#include <fstream>
using namespace std;

int main()

{  
   char fileName[80];       
   const int SIZE = 80;  
   int count = 0;
   char ch;
   fstream file;

	// Get filename
   cout << "Pease enter a filename: ";
   cin >> fileName;
   
   //Open the file
   file.open(fileName, ios::in);       
   if (!file)
   {
		cout << fileName << " Cannot open file, please check for file.\n";  // Error Opening file
        return 0;
   }

   // Get characters from file and display
   file.get(ch);
   while (!file.eof())
   {
       if(count==24)
    system("pause");
          count=0;

   }  
	 count++;
     cout << ch;
	 file.get(ch);
	 
	 {     

   file.close();
   system("pause");
   return 0;

	 }

unnecessary opening brace at line 39?

Could you please tell me why it does nothing after inputting a filename, I have the file in the correct place but it just sits there after entering

while (!file.eof())
   {
       if(count==24)
    system("pause");
          count=0;

   }

Looks like it is running an infinite loop.

Why should the EOF be reached? Also checking for EOF is not such a great practice.

while (!file.eof())
   {
       if(count==24)
    system("pause");
          count=0;

   }

Looks like it is running an infinite loop.

Why should the EOF be reached? Also checking for EOF is not such a great practice.

The program should read a file and display 24 lines of text per screen. should I be using something else

As the code stands it is not displaying anything on the screen, right?

You need to add the file reading part , display to screen part and a proper exit criteria inside the while loop to get it to work.

actually I just cut off the Program notes that at the beginning of the program. I next time. what I post is the full code minus the location, description, and filename information.

This article has been dead for over six months. Start a new discussion instead.