Missing '}' ?
Nov 15, 2010 at 11:45pm UTC
Here I have posted my code, followed by the error message. I cannot figure out where the two missing '}' are, because I only have two while statements, both of which are closed with brackets. Anyone know whats going on?
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
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
ifstream inStream;
ofstream outStream;
string inFile, outFile;
cout << "Enter the name of the file: " ;
cin >> inFile;
inStream.open(inFile.c_str( ));
while (inStream.fail( ))
{
cout << "\nInput file opening failed.\n" ;
cout << "Please enter a valid file name: " ;
cin >> inFile;
inStream.open(inFile.c_str( ));
{
cout << "Enter the name of output file: " ;
cin >> outFile;
outStream.open(outFile.c_str( ));
while (outStream.fail( ))
{
cout << "\nOutput file opening failed.\n" ;
cout << "Please enter a valid file name: " ;
cin >> outFile;
outStream.open(outFile.c_str( ));
}
inStream.close( );
outStream.close( );
return 0;
}
main.cpp: In function âint main()â:
main.cpp:48: error: expected `}' at end of input
main.cpp:48: error: expected `}' at end of input
Nov 15, 2010 at 11:52pm UTC
Line 28, you actually want a close bracket, not an open one.
Nov 16, 2010 at 12:00am UTC
wow lol, looked at that for too long to not see that. Thanks.
Nov 16, 2010 at 12:01am UTC
Heh, no problem. Better a silly typo than an actually annoying bug.
Topic archived. No new replies allowed.