为什么没有声明标题? [英] Why tthe header is not declared ?

查看:94
本文介绍了为什么没有声明标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨〜每一个〜我这里有一个小程序,当我试图编译

时,它总是提醒

arrary.c:在函数`main '':

arrary.c:39:错误:`header''unclaclared(首次使用此功能)

arrary.c:39:错误:(每个未声明的标识符只报告一次

arrary.c:39:错误:对于它出现的每个函数。)


为什么会这样?我想我已经宣布了。 :(


#include< stdlib.h>

#include< string.h>


typedef struct _HEADER {


短号num1;

短号num2;

短号num3;

短号num4;


} HEADER;


短i;


短x;

短y;

短z;

void readheader(HEADER *,FILE

*); ------- ------------------------------------这是第39行

void writeheader (HEADER *,FILE *);

main()


{


FILE * fp1;

FILE * fp2;


短***数据表;


fp1 = fopen(" g.dat" ,r,;

fp2 = fopen(" newdata.dat"," wb +");


readheader(标题, fp1);

writeheader(header,fp2);


for(x = 0; x< 2; x ++){

for(y = 0; y <3; y ++){

for(z = 0; z <4; z ++){


fwrite(& ;数据表[X] [Y] [Z],的sizeof (短),24,fp2);

fclose(fp1);

fclose(fp2);

}

}

}

}


void readheader(HEADER * header,FILE * fp1)

{

fread(&(header-> num1),sizeof(short),1,fp1);

fread(&(header-> num2),sizeof(短),1,fp1);

fread(&(header-> num3),sizeof(short),1,fp1);

fread(&(header-> num4),sizeof(short),1,fp1);

}


void writeheader(HEADER * header) ,FILE * fp2)

{

fwrite(&(header-> num1),sizeof(short),1,fp2);

fwrite(&(header-> num2),sizeof(short),1,fp2);

fwrite(&(header-> num3),sizeof(short),1 ,fp2);

fwrite(&(header-> num4),sizeof(short),1,fp2);

}

HI~ EVERY ONE~ I have a small program here, when I tried to compile
it , it always reminds that
arrary.c: In function `main'':
arrary.c:39: error: `header'' undeclared (first use in this function)
arrary.c:39: error: (Each undeclared identifier is reported only once
arrary.c:39: error: for each function it appears in.)

Why is that ? I think I have declared it . :(

#include<stdlib.h>
#include<string.h>

typedef struct _HEADER {

short num1;
short num2;
short num3;
short num4;

}HEADER;

short i;

short x;
short y;
short z;
void readheader(HEADER *,FILE
*);-------------------------------------------THIS IS LINE 39
void writeheader(HEADER *,FILE *);
main()

{

FILE *fp1;
FILE *fp2;

short ***datatable;

fp1=fopen("g.dat","r");
fp2=fopen("newdata.dat","wb+");

readheader(header,fp1);
writeheader(header,fp2);

for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){

fwrite(&datatable[x][y][z],sizeof(short),24,fp2);
fclose(fp1);
fclose(fp2);
}
}
}
}

void readheader(HEADER *header,FILE *fp1)
{
fread(&(header->num1),sizeof(short),1,fp1);
fread(&(header->num2),sizeof(short),1,fp1);
fread(&(header->num3),sizeof(short),1,fp1);
fread(&(header->num4),sizeof(short),1,fp1);
}

void writeheader(HEADER *header,FILE *fp2)
{
fwrite(&(header->num1),sizeof(short),1,fp2);
fwrite(&(header->num2),sizeof(short),1,fp2);
fwrite(&(header->num3),sizeof(short),1,fp2);
fwrite(&(header->num4),sizeof(short),1,fp2);
}

推荐答案

xiao写道:
xiao wrote:

嗨〜每一个〜我这里有一个小程序,当时我试着编译

吧,我总是提醒


arrary.c:在函数`main'':

arrary.c:39:错误:`header''未声明(首先在这个函数中使用)

arrary.c:39:错误:(每个未声明的标识符只报告一次

arrary.c:39:错误:对于每个函数它出现在。)


为什么?我想我已经宣布了。 :(
HI~ EVERY ONE~ I have a small program here, when I tried to compile
it , it always reminds that
arrary.c: In function `main'':
arrary.c:39: error: `header'' undeclared (first use in this function)
arrary.c:39: error: (Each undeclared identifier is reported only once
arrary.c:39: error: for each function it appears in.)

Why is that ? I think I have declared it . :(



哪里?


-

Ian Collins。

Where?

--
Ian Collins.


xiao写道:
xiao wrote:

嗨〜每一个〜我这里有一个小程序,当我尝试编译时

它,它总是提醒
HI~ EVERY ONE~ I have a small program here, when I tried to compile
it , it always reminds that


arrary.c:在函数`main'':

arrary .c:39:错误:`header''未声明(在此函数中首次使用)
arrary.c: In function `main'':
arrary.c:39: error: `header'' undeclared (first use in this function)



因为你没有声明它。

Because you didn''t declare it.


为什么会这样?我想我已经声明了。:(
Why is that ? I think I have declared it . :(



你为什么这么想?没有你代码中任何地方的任何一行

看起来像''header''的声明。

Why would you think that? There isn''t any line anywhere in your code
that looks remotely like a declaration of ''header''.


2008年7月19日星期六19: 10:37 -0700(PDT),xiao< li ********* @ gmail.com>

写道:
On Sat, 19 Jul 2008 19:10:37 -0700 (PDT), xiao <li*********@gmail.com>
wrote:

> HI~EVE RY ONE~我这里有一个小程序,当我尝试编译它时,它总是提醒

arrary.c:在函数`main'':
arrary。 c:39:错误:`header''未声明(首次使用此函数)
arrary.c:39:错误:(每个未声明的标识符仅报告一次
arrary.c:39:错误:对于它出现的每个功能。)

为什么?我想我已经宣布了。 :(


#include< stdlib.h>
#include< string.h>

typedef struct _HEADER {

短数字1;
短数字数字;
短数字数字;
短数字4;

} HEADER;

短i;

短x;
短y;
短z;

void readheader(HEADER *,FILE
*); ----- --------------------------------------这是第39行
void writeheader(HEADER *,FILE *);

main()

{/>
文件* fp1;
文件* fp2;

短***数据表;

fp1 = fopen(" g.dat"," r");
fp2 = fopen(" newdata.dat", wb +;;

readheader(header,fp1);
>HI~ EVERY ONE~ I have a small program here, when I tried to compile
it , it always reminds that
arrary.c: In function `main'':
arrary.c:39: error: `header'' undeclared (first use in this function)
arrary.c:39: error: (Each undeclared identifier is reported only once
arrary.c:39: error: for each function it appears in.)

Why is that ? I think I have declared it . :(

#include<stdlib.h>
#include<string.h>

typedef struct _HEADER {

short num1;
short num2;
short num3;
short num4;

}HEADER;

short i;

short x;
short y;
short z;
void readheader(HEADER *,FILE
*);-------------------------------------------THIS IS LINE 39
void writeheader(HEADER *,FILE *);
main()

{

FILE *fp1;
FILE *fp2;

short ***datatable;

fp1=fopen("g.dat","r");
fp2=fopen("newdata.dat","wb+");

readheader(header,fp1);



很可能这是实际的39行,因为它是你使用令牌头的第一个

的地方。你认为你在哪里定义了这个令牌应该引用的

对象?

More than likely this is the actual line 39 since it is the first
place you use the token header. Where do you think you defined the
object this token should refer to?


> writeheader(header,fp2);

for(x = 0; x< 2; x ++) {

for(y = 0; Y'LT; 3; y ++){

for(z = 0; z< 4; z ++){

fwrite(& datatable [x] [y] [z],sizeof(short ),24,fp2);

fclose(fp1);

fclose(fp2);
}
}
}
>writeheader(header,fp2);

for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){

fwrite(&datatable[x][y][z],sizeof(short),24,fp2);
fclose(fp1);
fclose(fp2);
}
}
}
}

void readheader(HEADER *header,FILE *fp1)



虽然完全合法,但读取和写入二进制数据的整数可以

严重限制了可移植性。

While perfectly legal, reading and writing integers as binary data can
severely limit portability.


> {
fread(&(header-> num1),sizeof(short ),1,fp1);
fread(&(header-> num2),sizeof(short),1,fp1);
fread(&(header-> num3),sizeof (短),1,fp1);
fread(&(header-> num4),sizeof(short),1,fp1);
}

void writeheader (HEADER *标题,FILE * fp2)
{/ / fwrite(&(header-> num1),sizeof(short),1,fp2);
fwrite(&(header) - > num2),sizeof(短),1,fp2);
fwrite(&(header-> num3),sizeof(short),1,fp2);
fwrite(& (header-> num4),sizeof(短),1,fp2);
}
>{
fread(&(header->num1),sizeof(short),1,fp1);
fread(&(header->num2),sizeof(short),1,fp1);
fread(&(header->num3),sizeof(short),1,fp1);
fread(&(header->num4),sizeof(short),1,fp1);
}

void writeheader(HEADER *header,FILE *fp2)
{
fwrite(&(header->num1),sizeof(short),1,fp2);
fwrite(&(header->num2),sizeof(short),1,fp2);
fwrite(&(header->num3),sizeof(short),1,fp2);
fwrite(&(header->num4),sizeof(short),1,fp2);
}



删除d el发送电子邮件


Remove del for email


这篇关于为什么没有声明标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆