子函数中那里有问题~!!??

[复制链接]
查看11 | 回复2 | 2006-4-20 18:53:45 | 显示全部楼层 |阅读模式
看你最后的输出语句,函数hanzi的输入参数应该是date 结构的指针吧!将函数声明void hanzi(int *); 改为void hanzi(date *); 实现也做相应的修改试试吧!
回复

使用道具 举报

千问 | 2006-4-20 18:53:45 | 显示全部楼层
子函数的参数类型改为struct date *p建议将printf("%d%s%d",(*p).year,month_name[(*p).month],(*p).day);改为 printf("%d%s%d", p->year, month_name[p->month],p->day);
回复

使用道具 举报

千问 | 2006-4-20 18:53:45 | 显示全部楼层
#include #include typedef struct date{ int year; int month; int day; } d1;void hanzi(struct date *); void main() { struct date d1;printf("以数字形式输入日期(年月日)\n"); printf("输入年:"); scanf("%d",&d1.year); printf("\n输入月:"); scanf("%d",&d1.month); printf("\n输入日:"); scanf("%d",&d1.day); if(d1.month==1||d1.month==3||d1.month==5||d1.month==7||d1.month==8||d1.month==10||d1.month==12) { if(d1.day=1) { hanzi(&d1); printf("\n");printf("%d %c %d",d1.year,d1.month,d1.day); } else { printf("输入错误\n"); exit(0); } } } void hanzi(struct date *p) { char month_name[][10]={" ","一", "二", "三", "四",
"五", "六", "七", "八",
"九", "十", "十一", "十二"}; printf("%d%s%d",p->year,month_name[(*p).month],(*p).day); }你自己试试吧!呵呵应该可以了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行