0
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 by tech9x: n/a

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by jonsca
0

try

#include <string>

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

0

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

strcpy (cstr, userInput);

Edited by geojia: n/a

1

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.