The following program is working properly with no error.
//***
#include
#include
#include
using namespace std;
void GetAndWrite(ifstream inFile);
int main()
{
ifstream inFile;
int number;
inFile.open("input.txt");
inFile >> number;
cout << "number" << " is " << number;
}
//***
But when i want to pass the input file to a function, some errors happen. i mean the following program doesn't work.
//*************************************
#include
#include
#include
using namespace std;
void GetAndWrite(ifstream inFile);
int main()
{
ifstream inFile;
inFile.open("input.txt");
GetAndWrite(inFile);
}
void GetAndWrite(ifstream inFile)
{
int number;
inFile >> number;
cout << "number" << " is " << number;
}
//***
i used Dev-C++ compiler, but why the second program is not working?
2006-11-04
13:50:08
·
2 answers
·
asked by
___
4
in
Computers & Internet
➔ Programming & Design