A little help with file I/O

For a basic c++ class I have to use a text file for input. I have the basic framework down but need help with a function call. The code for the function header for doAddition was provided as was the code to open the file. I need to know what to put in the function call for doAddition so I can send it the open text file.

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
char ch;

int main()
{
	ifstream inFile;
	inFile.open( "math.txt" );
	
	if( inFile.fail() )
  	{
  		cout << "The math.txt input file failed to open";
  		exit(-1);
  	}

	inFile >> ch;
	
	
	
	while ( inFile )
 	 {
  		switch(ch)
		{
			case '+': doAddition(I NEED TO KNOW WHAT GOES HERE);
		}
	
  	}
}



void doAddition( ifstream &inFile )
{
	
}
Last edited on
since you declared your ifstream as inFile, you need to use inFile in the call to the function.

doAddition(inFile);
got it working! thanks. Turns out i already had that but forgot the function prototype.
Topic archived. No new replies allowed.