⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_fwite.c

📁 这是一个飞机的C程序编写的代码,你能从中知道如何去订瓢
💻 C
字号:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SIZE 3
#define MAX 13
#define OK 1
#define TRUE 1
#define FALSE 0
#define ERROR 0
#define OVERFLOW -2
#define OPSETSIZE 7
#define STACK_INIF_SIZE 50
#define STACKINCREMENT 10
#define PR printf
#define SIZE 3
FILE *fp_airline,*fp_customer;
struct customer{
	char name[9];//顾客名
	char line_num[8];//航班号
	int seat_num;//座位号
//	struct customer *next;//下一个结点
}cus[3];
void main()
{
//	customer cus[3];
	int i=0;
	char filename[50]="c:\\customer.dat";
	char *name[3]={"欧阳锦林","尹焕亮","付胜"};
	char *line_num[3]={"bjnc01","bjsh02","shgz03"};
	int seat_num[3]={1,5,10};
	for (i=0;i<3;i++){
		strcpy(cus[i].name , name[i]);
		strcpy(cus[i].line_num , line_num[i]);
		cus[i].seat_num =seat_num[i];
//		cus[i].next=NULL;
	}
	if((fp_customer=fopen("filename","wb+"))==NULL)
	{
		printf("can not open file to write:%s\n",filename);
	}
	for (i=0;i<3;i++){
		if(fwrite(&cus[i],sizeof(struct customer),1,fp_customer)!=1)
		{
			PR("customer_dat write error\n");
			fclose(fp_customer);
		}
	}
	fclose(fp_customer);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -