X
xiao
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);
}
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);
}