跟着视频敲的代码,但是运行结果一直是错误的,检查好多遍也找不到错误,摆脱大家了,帮我看看问题出在哪里
- int main(int argc, const char * argv[]) {
- char str[100];
- int word = 0,count=0;
- printf("Input some words with lower case:\n");
- gets(str);
- for (int i = 0; str[i] != '\0'; i++) {
- if (str[i] == ' ') {
- word = 0;
- }else if (word == 0){
- count++;
- str[i] = str[i]-32;
- word = 1;
- }
- }
- puts(str);
- return 0;
- }
复制代码 |
|