Aug 4, 2015 at 7:23am UTC
#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;
}
Aug 4, 2015 at 7:37am UTC
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 Aug 4, 2015 at 7:44am UTC
Aug 4, 2015 at 7:40am UTC
thank u so much that error is resolved but anoter pops up
Expected ; before endl... in line 11 *12
Aug 4, 2015 at 7:42am UTC
cout<< "Num 1: " << xx endl ;
See anything missing here?
Last edited on Aug 4, 2015 at 7:42am UTC
Aug 4, 2015 at 7:46am UTC
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
Aug 4, 2015 at 7:47am UTC
IF you can use the code tags, we can see the line numbers and see proper indenting amongst other things.
ninja'd by Peter87