Passing filename as a string
Hi, me again!
I have this code:
Code:
char* getfilebits(char* filename)
{
char* ptr;
ifstream file (filename, ios::in|ios::binary); // open file for reading
if (file.is_open()) // did it open?
{
ptr=new char[16]; // make space for data
file.read(ptr, 16); //read data from file
file.close(); // close file, it is needed no longer
//return 0;
}else{
cout << "Could not open file" << endl;
terminate();
};
return ptr;
};
It works, but the fact that I need to take filename as a char* bugs me. Is there any way to get ifstream to accept a string as a file name?