c语言程序找不出问题

[复制链接]
查看11 | 回复3 | 2010-7-25 13:12:19 | 显示全部楼层 |阅读模式
# include
# include
struct student
{
int age;
char sex;
char name[100];
};

void inputstudent(struct student * pstu);
void outputstudent(struct student ss);
int main(void)
{
struct student st;

inputstudent(&st);
printf("%d %c %s\n",st.age, st.sex, st.name);
outputstudnet(st);
return 0;
}
void outputstudent(struct student ss)
{
printf("%d %c %s\n", ss.age, ss.sex, ss.name);
}
void inputstudent(struct student * pstu)
{
(* pstu).age = 10;
strcpy(pstu->name,"张三");
pstu->sex = 'f';
}
我是对着示例一个字母一个字母敲上面,可就是编译出错,能帮我看下毛病在哪吗?谢谢了。
我在Microsoft visual c++ 这个软件中,一点击Compile,软件下面的提示框就会显示:结构体变量输入输出.exe - 1 error(s), 0 warning(s)。我刚刚自学的。

回复

使用道具 举报

千问 | 2010-7-25 13:12:19 | 显示全部楼层
两个地方错误 错误一:outputstudnet(st);这句 应该outputstudent(st);错误2 strcpy(pstu->name,"张三");最后那个分号 是中文的了 strcpy(pstu->name,"张三");这样最终:# include # include struct student { int age; char sex; char name[100];};
void inputstudent(struct student * pstu);void outputstude
回复

使用道具 举报

千问 | 2010-7-25 13:12:19 | 显示全部楼层
int main(void){ struct student st;inputstudent(&st); printf("%d %c %s\n",st.age, st.sex, st.name); outputstudnet(st);//你打错了strcpy(pstu->name,"张三");//把这个分号改成英文
回复

使用道具 举报

千问 | 2010-7-25 13:12:19 | 显示全部楼层
你要说一下什么错误啊?就直接说有错,这编译链接这一系列过程随时可以出错,让大家怎么排除啊!
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行