File not passing to function.
This is my code in which i am getting some errors and my file is not passing to function.
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
|
#include<iostream>
#include<cmath>
#include<fstream>
#include<iomanip>
int cal(int& a);
void filling(ifstream &myFile);
using namespace std;
int main()
{
int a;
ifstream myFile;
myFile.open("in.txt");
filling(myFile);
system("pause");
return 0;
}
int cal(int& a)
{
a++;
return a;
}
void filling(ifstream &myFile)
{
int a;
myFile>>a;
cal(a);
cout<<a;
}
|
You have to write std::ifstream if you use ifstream before using namespace std;
Yeah Its now working thanks man.
Topic archived. No new replies allowed.