帮忙看看.从文件里提取数据的时候cannot open file
各位大哥帮忙看看...从文件里提取数据的时候cannot open file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#define SIZE 200
int flag;
struct flight /*定义结构体*/
{
char distination[10];
char price[5];
char month[5];
char day[5];
char year[5];
char hour[5];
char minute[5];
}flights[SIZE];
void save() /*把结构体的内容保存到文件中*/
{
FILE *fp;
int i=0;
if((fp=fopen( "flightfile.txt ", "w "))==NULL)
{
printf( "cannot open file\n ");
return;
}
for(i=0;i <SIZE;i++)
if(fwrite(&flights[i],sizeof(struct flight),1,fp)!=1)
{if(feof(fp)){fclose(fp);return;}
printf( "file read error\n ");
}
fclose(fp);
}
void load() /*把文件内容输出到结构体中*/
{
FILE *fp;
int i=0;
if((fp=fopen( "flightfile.txt ", "r "))==NULL);
{printf( "cannot open file\n ");return;}
while(feof(fp)!=1)
{
fread(&flights[i],sizeof(struct flight),1,fp);
i++;
return;
}
fclose(fp);
}
void input() /*从键盘向结构体输入信息*/
{ void winAdmin();
int i;
int j=1;
for(i=0;i <SIZE;i++)
if(j==1)
{ printf( "请输入航班的目的地:\n ");scanf( "%s ",flights[i].distination);
printf( "请输入机票的价格:\n ");scanf( "%s ",flights[i].price);
printf( "请输入航班的起飞日期(月份):\n ");scanf( "%s ",flights[i].month);
printf( "请输入航班的起飞日期(日期):\n ");scanf( "%s ",flights[i].day);
printf( "请输入航班的起飞日期(年份):\n ");scanf( "%s ",flights[i].year);
printf( "请输入航班的起飞时间(几点):\n ");scanf( "%s ",flights[i].hour);
printf( "请输入航班的起飞时间(几分):\n ");scanf( "%s ",flights[i].minute);
printf( "您还想再输入新的航班信息吗?(1.是/2.否)\n ");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#define SIZE 200
int flag;
struct flight /*定义结构体*/
{
char distination[10];
char price[5];
char month[5];
char day[5];
char year[5];
char hour[5];
char minute[5];
}flights[SIZE];
void save() /*把结构体的内容保存到文件中*/
{
FILE *fp;
int i=0;
if((fp=fopen( "flightfile.txt ", "w "))==NULL)
{
printf( "cannot open file\n ");
return;
}
for(i=0;i <SIZE;i++)
if(fwrite(&flights[i],sizeof(struct flight),1,fp)!=1)
{if(feof(fp)){fclose(fp);return;}
printf( "file read error\n ");
}
fclose(fp);
}
void load() /*把文件内容输出到结构体中*/
{
FILE *fp;
int i=0;
if((fp=fopen( "flightfile.txt ", "r "))==NULL);
{printf( "cannot open file\n ");return;}
while(feof(fp)!=1)
{
fread(&flights[i],sizeof(struct flight),1,fp);
i++;
return;
}
fclose(fp);
}
void input() /*从键盘向结构体输入信息*/
{ void winAdmin();
int i;
int j=1;
for(i=0;i <SIZE;i++)
if(j==1)
{ printf( "请输入航班的目的地:\n ");scanf( "%s ",flights[i].distination);
printf( "请输入机票的价格:\n ");scanf( "%s ",flights[i].price);
printf( "请输入航班的起飞日期(月份):\n ");scanf( "%s ",flights[i].month);
printf( "请输入航班的起飞日期(日期):\n ");scanf( "%s ",flights[i].day);
printf( "请输入航班的起飞日期(年份):\n ");scanf( "%s ",flights[i].year);
printf( "请输入航班的起飞时间(几点):\n ");scanf( "%s ",flights[i].hour);
printf( "请输入航班的起飞时间(几分):\n ");scanf( "%s ",flights[i].minute);
printf( "您还想再输入新的航班信息吗?(1.是/2.否)\n ");