#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