CodePudding user response:
Space with a const char * said, "" is a string, you can use the string. The data () method will turn const char * stringCodePudding user response:
Are there# include & lt; String. H>
CodePudding user response:
# include
#include
Int main (void)
{
Char input [16]=ABC, "" d";
Char * p;
/* strtok places a NULL terminator
Infront of the token, if found */
P=strtok (input, ", ");
If (p)
Printf (" % s \ n ", p);
/* Asecond call to strtok using a NULL
As the first parameter returns a pointer
To the character following the token */
P=strtok (NULL, ", ");
If (p)
Printf (" % s \ n ", p);
return 0;
}
# include
#include
using namespace std;
Int main ()
{
Char sentence []="This is a sentence with 7 tokens".
cout <"The string to be tokenized is: \ n" & lt;Char * tokenPtr=strtok (sentence, "");
While (tokenPtr!=NULL) {
CoutTokenPtr=strtok (NULL, "");
}
//cout & lt; <"After the strtok, sentence=" & lt;return 0;
}
Baidu encyclopedia of the above two examples, code compared with you, to see what was missing
CodePudding user response: