void getCommands(char * cstr,char * p,string *userInput,string Input)
{
     
     string currentCommand = "";
     strcpy (cstr, userInput.c_str());
     p = strtok (cstr," ");
       while (p!=NULL)
   {
    p=strtok(NULL," ");
    cout << p;
}

ERROR
`c_str' has not been declared
request for member of non-aggregate type before '(' token


I have #include <cstring>
WHY STILL DONT WORK!!!!!!!!!!!!!!!!!!!!! :(:(:(

Edited 6 Years Ago by tech9x: n/a

try

#include <string>

string.c_str() is a method for a string, and has nothing to do with including the cstring

Edit:
NVM your problem isn't the c_str(), userInput is already char.

strcpy (cstr, userInput);

Edited 6 Years Ago by geojia: n/a

Edit:
NVM your problem isn't the c_str(), userInput is already char.

strcpy (cstr, userInput);

userInput is a string * which means you have to dereference it using the -> operator, so userInput->c_str() @OP You still will need to include <string> if you are using std::string in your code.

This question has already been answered. Start a new discussion instead.