char *s[8] = { “littleken”, “knuthocean”, “dongfangxu”, “zap”, “kittig”, “robertcui”, “forest”, “flirly” }; 可
char **s = { “littleken”, “knuthocean”, “dongfangxu”, “zap”, “kittig”, “robertcui”, “forest”, “flirly” }; 不可
string类如何用scanf进行读取:
从控制台读入到字符串中 #include <stdio.h> #include <string> using namespace std; int main() { string a; a.resize(100); //需要预先分配空间 scanf("%s", &a[0]); puts(a.c_str()); return 0; } 如果是要从字符串中读出数据 string a; int n; sscanf(a.c_str(), "%d", &n); 读取字符串出错:
int calur(char* s){
int i = 0;
while (*(s+i)!=’\0′){
i++;
}
return i;
}