我想计算空格的数量。据我了解,编译器在这一行发誓isspace(s[step]) != 0。但有时代码启动并没有错误。我不知道为什么会这样。
char s[] = "So she was considering";
int number_space = 0, step = 0;
int length_string = strlen(s);
while(strlen(s) != step){
if(isspace(s[step]) != 0){
number_space++;
}
step++;
}
cout << number_space;