Converting a C++ style string into something execvp can use.
-
I have made a program to except user's input and use that input to execvp another program. The problem is that execvp has a prototype of int execvp(const char *file, char *const argv[]); and the user's input is a c++ style string (string input for instance). How can I convert that c++ style string into something at execvp can use? the c_str() function DOES NOT work.
-
I have made a program to except user's input and use that input to execvp another program. The problem is that execvp has a prototype of int execvp(const char *file, char *const argv[]); and the user's input is a c++ style string (string input for instance). How can I convert that c++ style string into something at execvp can use? the c_str() function DOES NOT work.
Which argument are you having trouble with ? What format is the string you're getting as input ? c_str() does indeed return a char *, if you've got a std::string. argv is an array of char *, not just a char *. What do you mean by 'it doesn't work'. A more meaningful error report would help those trying to help you. Christian Graus - Microsoft MVP - C++