鱼C论坛

 找回密码
 立即注册
查看: 4355|回复: 4

大家帮忙看看那什么情况,

[复制链接]
发表于 2013-9-15 14:18:29 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. # include <stdio.h>
  2. # include <string.h>

  3. void InputStudent(struct Studend * pst);
  4. void OutputStudent(struct Studend st);

  5. struct Studend
  6. {
  7.         int age;
  8.         char a[100];
  9.         char sex;
  10. };

  11. int main (void)
  12. {
  13.         struct Studend st;

  14.         InputStudent(&st);

  15.         OutputStudent(st);
  16.        
  17.         return 0;
  18. }

  19. void InputStudent(struct Studend * pst)
  20. {
  21.    (*pst).age = 10;
  22.     strcpy(pst->a, "李四");
  23.    pst->sex = 'F';
  24. }

  25. void OutputStudent(struct Studend st)
  26. {
  27.         printf("%d %c %c", st.age, st.a, st.sex);
  28. }
复制代码


小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-9-15 14:19:06 | 显示全部楼层
--------------------Configuration: vdgvdbc - Win32 Debug--------------------
Compiling...
vdgvdbc.c
D:\Hei\编程程序\vdgvdbc.c(5) : error C2079: 'st' uses undefined struct 'Studend'
D:\Hei\编程程序\vdgvdbc.c(20) : error C2115: 'function' : incompatible types
D:\Hei\编程程序\vdgvdbc.c(20) : warning C4024: 'OutputStudent' : different types for formal and actual parameter 1
D:\Hei\编程程序\vdgvdbc.c(33) : warning C4028: formal parameter 1 different from declaration
执行 cl.exe 时出错.

vdgvdbc.obj - 1 error(s), 0 warning(s)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2013-9-15 14:50:56 | 显示全部楼层
把结构定义放函数声明前面
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2013-9-15 16:08:23 | 显示全部楼层

把void InputStudent(struct Studend * pst);

void OutputStudent(struct Studend st);放在结构体后面

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-9-16 16:51:56 | 显示全部楼层
谢谢俩位帮助,已经解决了。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-6 10:56

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表