写了个,关于指针的问题,求解决
程序就是为了实现计算一个字符串白空个数和小写字符个数如下,运行完了结果是这样,和预想的不一致,求高手帮忙看看是哪有问题,自己刚学指针,指针还不太了解Process returned -1073741819 (0xC0000005) execution time : 1.911 s
Press any key to continue.
#include <stdio.h>
int get(a,b)
int *a,*b;
{char c;
*a=0;
*b=0;
int i=0;
char s[21];
s[21]="wo shi zhong guo ren";
for(i=0;s[i]!='\0';i++)
switch(s[i])
{case ' ':
case '\t':(*a)++;break;
case '\n':return(1);
default: if(s[i]>='a'&&s[i]<='z')(*b)++;
}
return (0);
}
int main()
{int *ws,*lc;
if(get(ws,lc))
{printf("有%d个白空\n",*ws);
printf("有%d小写字符\n",*lc);
}
else printf("输入不正确\n") ;
}