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;

	 }

Recommended Answers

All 8 Replies

Check your brackets again, It looks like you have 4-{ and only 3-}.

unnecessary opening brace at line 39?

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

Read this
http://cboard.cprogramming.com/c-programming/88495-development-process.html

Then get into the habit of writing code in small steps, and compiling often.

> Error 1 fatal error C1075: end of file found before the left brace '{' at line 50
But your paste has only 45 lines!?
So you've either posted some irrelevant code, or you've hacked it to bits to post something reasonably short.
Neither of which is any use at all for us to tell you where the problem is.

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.

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.