Hey guys. I have a horrible problem with passing strings in a function and using the string to open an input file. Could you guys give me a hand?
#include "pe3.h"
int main ()
{
int ary[ SIZE ] ;
ifstream inp ;
string iNam ;
cout << "Input-file name: " ;
getline( cin , iNam ) ;
openInFile( ifstream & inp , string iNam ) ;
readData( ifstream & inp , int ary[] , int SIZE ) ;
return 0 ;
}
int openFile( ifstream & inFile , string inFileName )
{
inFile.open( inFileName.c_str() ) ;
if ( !inFile )
{
cout << "\n!! File '" << inFileName << "' not found -- check path !!" ;
return 1 ;
}
return 0 ;
}
I get this error:
error C2275: 'std::ifstream' : illegal use of this type as an expression
at the openFile function call