How do I convert a C char* into a C++ char?
Any help is highly appreciated.
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*How do I convert a C char* into a C++ char?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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 .
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));
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.