主题:[讨论]结构体的引用出问题了
# include <stdio.h>
#include <math.h>
struct datainfo
{
float lon;
float lat;
int day;
int seconds;
int micros;
int cycle;
int pass;
}data;
void DataCountx(char infile[255],char outfile[255])
{
FILE *fin,*fout;
fout=fopen(outfile,"w");
if ((fin=fopen(infile,"rb") )==NULL)
{printf("can not open the inputfile \n");}
while (!feof(fin))
{
fread(&data,sizeof(struct datainfo),1,fin);//
fwrite(&data,sizeof(struct datainfo),1,fout);//这样可以
printf("%d \n",data.day);//这样的话,在屏幕上看不到正确的data.day值 ,这是为什么,请指教,非常感谢
}
fclose(fin);
fclose(fout);
}
#include <math.h>
struct datainfo
{
float lon;
float lat;
int day;
int seconds;
int micros;
int cycle;
int pass;
}data;
void DataCountx(char infile[255],char outfile[255])
{
FILE *fin,*fout;
fout=fopen(outfile,"w");
if ((fin=fopen(infile,"rb") )==NULL)
{printf("can not open the inputfile \n");}
while (!feof(fin))
{
fread(&data,sizeof(struct datainfo),1,fin);//
fwrite(&data,sizeof(struct datainfo),1,fout);//这样可以
printf("%d \n",data.day);//这样的话,在屏幕上看不到正确的data.day值 ,这是为什么,请指教,非常感谢
}
fclose(fin);
fclose(fout);
}