#include <iostream>
#include <string.h>
using namespace std;
int main() {
char *tok;
string s = "Ana and Maria are dancing.";
tok = strtok(s.c_str(), " ");
while(tok != NULL) {
cout << tok << " ";
tok = strtok(NULL, " ");
}
return 0;
}
而且我得到这个错误:错误尝试使用“的strtok”的字符串
:9:29: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
In file included from ceva.cc:2:0:
348:14: error: initializing argument 1 of ‘char* strtok(char*, const char*)’ [-fpermissive]"
你应该考虑改变剧情,我的意思是安娜和玛丽亚正在做什么,或者这个问题会被标记为冒犯性的。 – biggdman 2013-05-11 09:10:52