原题是要求输入的字符串长度,换行为结束,空格不在长度内
我用了gets输入,想通过判断每一个字符是否为空格来实现,但好像不行```c
#include
#include
#include<math.h>
#include
#include<string.h>
using namespace std;
int main(){
char s[34234];
int num=0,length;
gets(s);
length=strlen(s);
for(int i=0;i<length;i++)
{
if(s[i]!='\0')num++;
}
cout<<num;
return 0;
}