返回信息流//统计字符串中字母,数字,空格和其他字符的个数
#include<stdlib.h>
#include<stdio.h>
#define SIZE 50
void Statistics(char *str[],int *letter,int *digit,int *space,int *others);
main()
{
char str[SIZE];
int lcount=0,ncount=0,scount=0,ocount=0;
printf("input string:\n");
gets(str);
Statistics(&str,&lcount,&ncount,&scount,&ocount);//!!!!!!!!!!!!!!!!!!!!!!!!!!!
printf("String: ");
puts(str);
printf("Letter: %d, digit: %d, space: %d, others: %d\n",lcount,ncount,scount,ocount);
system("pause");
return 0;
}
void Statistics(char *str[],int *letter,int *digit,int *space,int *others)
{
int i;
for(i=0;str[i]!='\0';i++)
{
if(*str[i]>='a'&&*str[i]<='z'||*str[i]>='A'&&*str[i]<='Z')
*letter++;
if(*str[i]==' ')
*space++;
if(*str[i]<='0'&&*str[i]<='9')
*digit++;
}
*others=i-1-*letter-*space-*digit;
}
错误是说16 [Warning] passing arg 1 of `Statistics' from incompatible pointer type
是带感叹号!那一行出了问题!,是什么问题呢,求教啊!!!
这是一条镜像帖。来源:北邮人论坛 / cpp / #17537同步于 2008/12/14
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
求助,C编译错误!!!
panyx0718
2008/12/14镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
Statistics(str,&lcount,&ncount,&scount,&ocount);
改写
void Statistics(char str[],int *letter,int *digit,int *space,int *others)
另外,就算你传进去的参数没问题,这个程序在指针和数组的使用上简直惨不忍睹,得到的肯定不是你想要的结果
我觉得你还是把c语言里 指针、数组 再重新看看吧。。。。
re
这部分是C语言基础中最重要的一部分,LZ再好好看看书吧
【 在 rebirthatsix 的大作中提到: 】
: 另外,就算你传进去的参数没问题,这个程序在指针和数组的使用上简直惨不忍睹,得到的肯定不是你想要的结果
: 我觉得你还是把c语言里 指针、数组 再重新看看吧。。。。