Error while Compiling : Expected ; before int

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main (){
ifstream inFile;
inFile.open(":C:/Users/Saad/Documents/numbers.txt")
int xx, yy;
inFile >> xx >> yy;
cout<< "Num 1: " << xx endl;
cout<< "Num 2: " << yy endl;
return 0;
}
Hi & Welcome to cplusplus,

You are missing a semicolon at the end of the line with inFile.open

Please use code tags - select all your code then press the <> button of the format menu on the right.

Good Luck :+)

Edit:

You also need more << operators on these lines:

1
2
cout<< "Num 1: " << xx << endl;
cout<< "Num 2: " << yy << endl;


Even better, don't use endl, it flushes the buffer and that can be inefficient, although it won't make a gnat of difference for your program though:

1
2
cout<< "Num 1: " << xx << "\n";
cout<< "Num 2: " << yy << "\n";

Last edited on
thank u so much that error is resolved but anoter pops up
Expected ; before endl... in line 11 *12
 
cout<< "Num 1: " << xx endl;

See anything missing here?
Last edited on
hi Peter,
after long time i started working on C++, so there are errors ... initially i use turbo c ....
so there are difference in syntax
please suggest the error
thanks in advance
-
Adnan
IF you can use the code tags, we can see the line numbers and see proper indenting amongst other things.

ninja'd by Peter87
Topic archived. No new replies allowed.