LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1698|回复: 17

一个C语言程序问题

[复制链接]
发表于 2003-12-9 09:34:17 | 显示全部楼层 |阅读模式
我的程序出了个错误,请大侠们看看什么问题!
程序片段如下:

1   struct Number {
2   ...
3   Number *next;
4   };
5
6   typedef struct {
7   ...
8   } Match;
9
10  struct SchoolReport {
11  ...
12  SchoolReport *next;
13  };
14
15  struct SchoolReport *compute(match[],m,n)
16  int m,n;
17  Match match[n];
18  {
19  ...
20  }

然后编译说第17行出错.
发表于 2003-12-9 10:30:40 | 显示全部楼层
15 line is error!
发表于 2003-12-9 10:40:39 | 显示全部楼层
15 struct SchoolReport *compute(match[],m,n)
16 int m,n;
17 Match match[n];


是不是参数的顺序问题?
发表于 2003-12-9 12:13:50 | 显示全部楼层
15 struct SchoolReport *compute(match[],m,n)
16 int m,n;
为什么要用这种写法?

1 struct Number {
2 ...
3 Number *next;
4 };
第三行应该为struct Number *next;吧,这是C,不是C++。
 楼主| 发表于 2003-12-9 15:04:55 | 显示全部楼层
抱歉,第3行笔误:
应为 3 struct Number *next;


15 struct SchoolReport *compute(match[],m,n)
16 int m,n;
为什么要用这种写法?

回答diver:

这是我做的一个小练习,compute函数要调用Match类型的数组变量来生成并初始化一个SchoolReport类型的变量.
你认为有更好的解决方法吗?
发表于 2003-12-9 16:04:13 | 显示全部楼层
这种函数定义的格式已经过时了。
struct SchoolReport *compute(Match match[],int m,int n)
 楼主| 发表于 2003-12-9 16:05:38 | 显示全部楼层
cgl520cn:15 line is error!

回答cgl520cn:
能具体说说15行的问题吗?我也觉得15行的代码有点不妥.
 楼主| 发表于 2003-12-9 16:10:07 | 显示全部楼层
pupilzeng:
这种函数定义的格式已经过时了。
struct SchoolReport *compute(Match match[],int m,int n)

回答pupilzeng:
你觉得该怎么定义?
struct SchoolReport *compute(Match match[],int m,int n)
你指该这么写吗?
发表于 2003-12-9 16:14:06 | 显示全部楼层
最初由 uci 发表
pupilzeng:
这种函数定义的格式已经过时了。
struct SchoolReport *compute(Match match[],int m,int n)

回答pupilzeng:
你觉得该怎么定义?
struct SchoolReport *compute(Match match[],int m,int n)
你指该这么写吗?

 楼主| 发表于 2003-12-9 16:17:31 | 显示全部楼层
回答pupilzeng:
但是我估计这么写还是有错误.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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