#include <iostream>\n#include <string.h>\nusing namespace std;\n\nint main() {\nchar *tok;\nstring s = "Ana and Maria are dancing.";\ntok = strtok(s.c_str(), " ");\nwhile(tok != NULL) {\n cout << tok << " ";\n tok = strtok(NULL, " ");\n}\nreturn 0;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n我收到此错误:
\n\n:9:29: error: invalid conversion from \xe2\x80\x98const char*\xe2\x80\x99 to \xe2\x80\x98char*\xe2\x80\x99 [-fpermissive]\nIn file included from ceva.cc:2:0:\n348:14: error: initializing argument 1 of \xe2\x80\x98char* strtok(char*, const char*)\xe2\x80\x99 [-fpermissive]"\n
Run Code Online (Sandbox Code Playgroud)\n v它是一个int数组,它是一个int:
#include <iostream>
using namespace std;
int main() {
int v[10], a;
cout << v[a] << endl;
cout << a[v] << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
返回相同的值:0 0
这是为什么 ?