Wish you all a good day.Currently i'm working on c++ project.I want to know how to convert string object to a character array.Also why ifstream object doesn't accept a string variable as follows,
void split(String filename)
{
ifstream ifile;
ifile.open(filename);//this fails

}

I guess you need to pass filename.c_str() .

Wish you all a good day.Currently i'm working on c++ project.I want to know how to convert string object to a character array.Also why ifstream object doesn't accept a string variable as follows,
void split(String filename)
{
ifstream ifile;
ifile.open(filename);//this fails

}

A string already is a character array. See this post.
http://www.daniweb.com/forums/thread117321.html
If you want to open a file where filename is a string, you need to use the c_str () function:

ifile.open(filename.c_str ());
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.