Im trying to open a file by its Path Specification, storing the character sequence in a character array. I can do this with strings, but i want to know the error i am getting with a c_string......
usingnamespace std;
int main()
{
char cArray[ 100 ] = {};
ifstream inFile;
cout << "Enter a path: ";
cin.getline( cArray, 100 );
inFile.open( cArray );
if ( !inFile.is_open() )
return -1; // statement should not execute! It should be open!
if ( !inFile )
return -1; // statement should not execute! I know it exists!
inFile >> cArray;
while ( !inFile.eof() )
{
// parse contents of file
}
inFile.close();
cin.ignore();
return 0;
}
So why cant i specify the path to open the file?
it gets stored in the cArray..
Note that i do not want to append anything.
I just want to open the file by its path. And not by its name.