gets遇到空格就不读了用int i = 0;while (1){char ch = getchar();if (ch == '\n') { str[i] = '\0'; break; }str[i++] = ch;}代替 gets(str);