| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1659 人关注过本帖
标题:请高手帮忙,程序错哪里了?用GCC编译器
只看楼主 加入收藏
flybird40000
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-12-6
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
请高手帮忙,程序错哪里了?用GCC编译器
#include <stdio.h>
#include <string.h>
#define N 2
void input_e(num,name)
int num[];
char name[N][8];
{
int i;
for(i=0;i<N;i++)
{
printf("\n输入职工号: ");
scanf("%d", &num[i]);
printf("\n 输入职工名: ");
getchar();
gets(name[i]);
}


}


main()
{
int num[N];
char name[N][8];
input_e(num,name);

}


4: error: variable or field `input_e' declared void
4: error: `num' was not declared in this scope
4: error: `name' was not declared in this scope
5: error: initializer expression list treated as compound expression
5: error: expected `,' or `;' before "int"
7: error: expected unqualified-id before '{' token
7: error: expected `,' or `;' before '{' token
In function `int main()':
24: error: `input_e' cannot be used as a function
搜索更多相关主题的帖子: GCC num name int expected 
2017-12-19 16:12
flybird40000
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-12-6
收藏
得分:0 
用vc6.0运行可以通过,但是用gcc编译器3.4.0版本,运行出现如下错误

4: error: variable or field `input_e' declared void
4: error: `num' was not declared in this scope
4: error: `name' was not declared in this scope
5: error: initializer expression list treated as compound expression
5: error: expected `,' or `;' before "int"
7: error: expected unqualified-id before '{' token
7: error: expected `,' or `;' before '{' token
In function `int main()':
24: error: `input_e' cannot be used as a function
2017-12-19 16:16
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10539
专家分:42927
注 册:2014-5-20
收藏
得分:20 
#include <stdio.h>
#include <string.h>
#define N 2
void input_e(int num[N], char name[N][8])
{
    int i;
    for(i=0; i<N; i++)
    {
        printf("\n输入职工号: ");
        scanf("%d", &num[i]);
        while (getchar()!='\n') NULL;
        printf("\n 输入职工名: ");
        gets(name[i]);
    }
}

main()
{
    int num[N];
    char name[N][8];
    input_e(num,name);
}
2017-12-19 16:38
flybird40000
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-12-6
收藏
得分:0 
弱弱的问一下,为什么这么改写?原理是什么?
2017-12-19 18:11
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:451
帖 子:10539
专家分:42927
注 册:2014-5-20
收藏
得分:0 
以下是引用flybird40000在2017-12-19 18:11:37的发言:

弱弱的问一下,为什么这么改写?原理是什么?

是指哪的改写?
2017-12-19 20:05
快速回复:请高手帮忙,程序错哪里了?用GCC编译器
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015370 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved