#include <stdio.h> #include <string.h>

int main() { char str[100]; int count = 0;

printf('Enter a string:');
fgets(str, sizeof(str), stdin);

for (int i = 0; i < strlen(str); i++) {
    if (str[i] == ' ') {
        count++;
    }
}

printf('%d', count + 1);

return 0;

}


原文地址: https://www.cveoy.top/t/topic/piln 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录