How do I convert a C char* into a C++ char?
Any help is highly appreciated.
Printable View
How do I convert a C char* into a C++ char?
Any help is highly appreciated.
Perhaps you mean to ask how to convert a char* to a std::string? If that's the case, then you would use the std::string constructor that accepts a const char*Quote:
How do I convert a C char* into a C++ char?
Thanks for your help!
I've just found a way. I use a temporary string "dept", and it works!
getline(in, data[count]);
dept = data[count];
department = dept[0];
out << department << endl;
count++;
getline() accepts C++ style strings, so that is a lot of extra work you are going through :D.
Actually, it looks like thiago_j is using the string version of getline.
Regardless, there is no need for a temporary string there. data[count][0] is the same as your use of dept. You can use out << data[count][0] << endl.
You don't need a (named) temporary string.
Code:a_function_that_requires_a_string(std::string(a_char_array));