In this method,
void mainRoutine(char *pattern, string searchPattern)
{
cout << "Please enter the string pattern to be searched: " << endl;
getline(cin, searchPattern);
ifstream filename(searchPattern.c_str());
while(filename.good() && filename.peek() != EOF)
{
cout << (char)filename.get();
}
cout << "\n";
char *pattern = (char *)filename;
}
When the user inputs a string - the filename to be taken in, I want to convert this string into a char so I can use it in other methods. How can I do this?
char*fromstd::stringis simple - callc_str()method on the string.