热门标签 | HotTags
当前位置:  开发笔记 > 运维 > 正文

怎么用linux里的make命令编译?

怎么用linux里的make命令编译?--Linux通用技术-Linux编程与内核信息,下面是详情阅读。
这是一个小商品管理系统的代码,想用linux的make命令来编译调试,但是不知道这个makefile文件怎么做,请教高手指教。代码如下:
这是顾客登陆模块
源文件:login.c
头文件:user.h

login.c
/*login.c: 顾客登录,判断顾客登录名、密码和权限,
根据权限调用相应功能选择界面*/
/*包含顾客信息头文件
包含创建顾客信息、增加、删除、修改、排序的顾客处理程序
包含管理员、普通顾客的功能选择界面处理程序*/
#include "user.h"
#include "cuser.c"
#include "admin.c"
#include "guest.c"
#include "adduser.c"
#include "deluser.c"
#include "sunum.c"
#include "munum.c"
int main( )
{
FILE *fp = NULL;
user Show;
user Tmps; /*临时存放顾客信息的结构体变量*/
char DataFile[40] = "yonghu"; /*存放顾客信息的文件名为yonghu*/
int i;
char relogin; /*是否重新登录的标志*/
int success=0; /*登陆成功的标志*/
/*CreatUser( );*/
printf("#===========================================#\n");
printf("# Welcome to the Product Management System! #\n");
printf("============================================#\n");
again:
/*输入登录名*/
printf("please enter the user name:");
scanf("%s",Tmps.Name);



/*输入密码,用不带回显的方式保证安全性*/
printf("password=");
for(i=0;i<6;i++)
{
Tmps.ps=gatch( );
}


Tmps.ps[6]='\0';
/*打开yonghu文件,用来验证登录名和密码*/
fp=fopen(DataFile,"rb");
if (fp == NULL)
{
printf("\nOpen file%sfail!End with any key \n",DataFile);
perror("\OPen file fail");
getch( );
exit(1);
}
/*循环读取文件校验登录名和密码是否正确*/
while(fread(&Show,sizeof(user),1,fp) != (int)NULL)
(
/*如果通过验证,则将success成功登录标记设为1*/
if((strcmp (Tmps.Name,Show.Name)==0)&&(strcmp(Tmps.ps,Show.ps)==0))
{
printf("\nlogin successful!\n");
success=1;
/*判断权限,如power的值为1,则是管理员,并调用管理员功能选择界面*/
if(Show.power==1)
{
printf("\nyour power is administrator!\n");
admin( );/*调用管理员系统主控平台*/
)
/*判断权限,如power的值为0,则是普通顾客,并调用普通顾客功能选择界面*/
if(Show.power==0)
{
printf("\nyour power is user!\n");
Guest( );/*调用普通用户系统主控平台*/
}
}
}
/*如未能成功登录,让顾客选择重新登录或推出*/
if(success==0)
{
getchar( );
printf("\nerror user name or password!input again?(y/n)");
scanf("%c",&relogin);
if((relogin=='Y')!!(relogin=='y'))
{
printf("you choose input again:\n");
goto again;)
else
{
printf("end program");
getch( );
exit(0);
}
}
}


user.h
/*===================user.h========================================*/
#include "stdio.h"
#include
#include
#include
#define SIZE 100
typedef struct
{
long Number; /*顾客序号*/
char Name[20]; /*顾客名称*/
char ps[8]; /*顾客密码*/
int power; /*顾客权限*/
}user;
extern void Guest( ); /*普通客户功能选择界面*/
extern void Admin( ); /*管理员功能选择界面 */
extern void CreatUser( ); /*创建客户信息文件 */
extern void AddUser( ); /*增加顾客记录 */
extern void DelUser( ); /*删除客户记录 */
extern void ModifyByUserNumber( ); /*根据顾客序号修改 */
extern void SortByUserNum( ); /*根据顾客序号排序浏览*/

这个是商品信息管理模块的代码
程序清单(1):shead.h
#include "stdio.h"
#include "stdio.h"
#include
#include
#include
#define SIZE 100 /* mac.ros definition*/
typedef struct
{
long Number; /*Field of number */
char Name[20]; /*Field of name */
float price; /*Field of price */
float discount; /*Field of discount */
float memberprice; /*Field of memberprice */
}product;
extern void CreatFile( ); /*创建信息文件*/
extern void AddRecord( ); /*增加 */
extern void DelRecord( ); /*删除 */
extern void ModifyByNumber( ); /*修改 */
extern void QueryBySeatNum( ); /*按序号查询 */
extern void QueryByName( ); /*按姓名查询 */
extern void SortByMemberprice( ); /*按合计查询 */

程序清单(2):admin.c
/*admin.c:管理员功能选择界面,根据客户选项调用相应函数实现系统功能*/
#include "shead.h"
#include "creat.c"
#include "add.c"
#include "delete.c"
#include "modnum.c"
#include "qname.c"
#include "qseatnum.c"
#include "smprice.c"
void Admin( )
{
int choice = 0;/*存放客户选项的变量*/
/*====功能及操作的界面提示====*/
while(1)
{
printf("--------------------------------------------------------------------------------------\n");
printf("| |\n");
printf("| Welcome to Product Management System |\n");
printf("| |\n");
printf("|-------------------------------------------------------------------------------------|\n");
printf ("| 1. Init Product Information File |\n");
printf("| 2. AddProduct( ) |\n");
printf("| 3. DelProdut( ) |\n");
printf("| 4. QueryByProductName( ) |\n");
printf("| 5. QueryByProductNum( ) |\n");
printf("| 6. ModifyByProductNumber( ) |\n");
printf("| 7. SortByMemberPrice( ) |\n");
printf("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("| System User Management |\n");
printf("| 11. CreatNewUserFile( ) |\n");
printf("| 12. AddUser( ) |\n");
printf("| 13. DelUser( ) |\n");
printf("| 14. ModifyUser( ) |\n");
printf("| 15. SortByUserNum( ) |\n");
printf("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("| 0. Exit System |\n");
printf("----------------------------------------------------------------------------------------\n");
printf("# Please Input Your Choose #\n");
printf("# number 1~7 to Mange the Product Information #\n");
printf("# number 11,12,13,14,15 to Mange the System User #\n");
printf("# number 0 to Exit the System #\n");
printf("-----------------------------------------------------------------------------------------\n");
scanf("%d",&choice);
getchar( );
/*根据客户选项调用相应函数*/
switch(choice)
{
case 1:
CreatFile( );
break;
case 2:
AddRecord( );
break;
case 3:
DelRecord( );
break;
case 4:
QueryByName( );
break;
case 5:
QueryBySeatNum( );
break;
case 6:
ModifyByNumber( );
break;
case 7:
SortByMemberPrice( );
break;
case 11:
CreatUser( );
break;
case 12:
AddUser( );
break;
case 13:
DelUser( );
break;
case 14:
ModifyByUserNumber( );
break;
case 15:
SortByUserNum( );
break;


case 0:
exit(0);
default:
break;
}
}
}
程序清单(3):creat.c
/*creat.c:用于创建商品信息文件*/
#include "stdio.h"
/*函数CreatFile*/
void CreatFile( )
{
FILE *fp = NULL; /*定义指向文件的指针*/
product Tmps; /*定义进行操作时存放结构体变量的*/
char DataFile[40] = ""; /*存储商品信息的文件名*/
int count = 1; /*计算可输入数据的最大范围*/
/*====输入存放商品信息的文件名====*/
printf("\n please input new file name of product information.");
printf("\n Notice:Name of file can't exceed 8 characters.suffix can't
exceed 3 characters,part of exceed will be discarded.\n");
gets(DataFile);
/*如顾客没有输入,则循环提示顾客输入*/
while(*DataFile == ('\0'))
{
printf("\n please input new file name to store data,end with enter.");
printf("\n Notice:Name of file can't exceed 8 characters,suffix can't
exceed 3 characters.part of exceed will be discarded.\n");
gets(DataFile);
}
/*用二进制写的方式打开文件,即创建文件*/
fp = fopen(DataFile,"wb+");
/*如果当前文件不存在,提示打开文件失败*/
if (fp == NULL)
{
printf("\n Open file %s fail!End with any key.\n",DataFile);
printf("Open file fail");


gatch( );
exit(1);
}
/*如果成功打开或创建文件,则提示输入商品序号、名称、价格要素等相关信息*/
printf("input product information record.number is 0 means input is end.\n");
printf("Number is not exceed 9 figures,Name is not exceed 20 characters,range of grade:0.00~1000.00\n");
/*循环从键盘上读取顾客输入的序号、名称、价格要素等相关信息*/
while(count <= SIZE)
{
/*输入序号,如为0则停止输入*/
printf("\n input 'number = 0' means end input .\n");
printf("number=");
scanf("%ld",&Tmps.Number);
if (Tmps.Number == 0 )
break;







/*提示输入商品名称*/
printf("name=");
scanf("%s",Tmps,Name);

/*提示输入商品的商品价格*/
printf("price=");
scanf("%f",&Tmps.price);

/*提示输入商品折扣*/
printf("discount=");
scanf("%f",&TmpS.discount);

/*用公式自动计算会员价*/
TmpS.memberprice=TmpS.price*TmpS.discount;


printf("\n");
/*如遇无法写入文件的异常,则加以提示*/
if(fwrite(&TmpS,sizeof(product),1,fp)!=1
{
printf("\nwrite file %s fail!End with any key\n",DataFile);
perror("write file fail ");
getch( );
exit(1);
}
}
count++;
}
/*如果输入的数据量超过最大允许的范围,则提示数据不能录入*/
if (count>SIZE)
printf(*\nsorry,number of data can not exceed%d\n",SIZE);
fclose(fp);
/*====在屏幕上显示文件内容====*/
/* clrscr( );*/
printf(*The data you input is store successful %s in file.\n*,DataFile);
printf("Countent as follow:\n");
fp=fpen(DataFile,"rb");
if (fp==NULL)
{
printf("\nopen file%sfail!End with any key \n",DataFile);
perror("Open file fail");
getch( );
exit(1);
}



printf("\nNumber\tName\tprice\tdiscount\tmemberprice\n");
while(fread(&TmpS,sizeof(product),1,fp) != (int)NULL)
{
printf("\n%ld\t%s\t%4.2f\t%4.2f\t\t4.2f\n",TmpS.Number,
TmpS.Name,TmpS.price,TmpS.discount,TmpS.memberprice);
}


fciose(fp);
}
程序清单(4):add.c
/*add.c:添加商品信息记录*/
#include "stdio.h"
void AddRecord( )
{
FILE *fp = NULL; /*定义指向文件的指针*/
product TmpS; /*定义进行操作时的临时结构体变量*/
char DataFile[40] = ""; /*存储商品信息的文件名*/
int count = 1; /*计算可输入数据的最大范围*/
/*====输入要添加商品信息的文件名====*/
printf("\n please input the product information file name to add record:");
printf("\n Notice:Name of file can'texceed 8 characters.suffix can't
exceed 3 characters,part of exceed will be discarded.\n");
gets(DataFile);
/*如顾客没有输入,则循环提示顾客输入*/
while(*DataFile == ('\0'))
{
printf(*\n please input new file name to store data,end with enter.");
printf("\n Notice:Name of file can'texceed 8 characters,suffix can't
exceed 3 characters.part of exceed will be discarded.\n");
gets(DataFile);
}


fp = fopen (DataFile,"a+");/*a+:当文件存在时,追加,当文件不存在时,创建*/
/*如果当前文件不存在,提示打开文件失败*/
if (fp == NULL)
{
printf(*\n Open file %s fail!End with any key.\n*,DataFile);
perror("Open file fail");


getch( );
exit(1);
}
/*如果成功打开或创建文件,则提示输入商品序号、名称、价格要素等相关信息*/
printf("input number,name and salary.number is 0 means input is end.\n");
printf("Number is not exceed 9 figures,Name is not exceed 20 characters,range of grade:0.00~1000.00\n");
/*循环从键盘上读取顾客输入的序号、名称、价格要素等相关信息*/
while(count <=SIZE)
{
/*输入序号,如为0则停止输入*/
printf("\n input 'number =0' means end input.\n");
printf("number=");
scanf("%ld",&TmpS.Number);
if (TmpS.Number == 0 )
break;
/*提示输入商品名称*/
printf("name=");
scanf("%s",TmpS.price);

/*提示输入商品价格*/
printf("price=");
scanf("%f",&TmpS.price);

/*提示输入商品折扣*/
printf("discount=");
scanf("%f",&TmpS.discount);


/*用公式自动计算商品会员价*/
TmpS.memberprice=TmpS.price*TmpS.discount;


printf("\n");
/*如遇无法写入文件的异常,则加以提示*/
if(fwrite(&TmpS,sizeof(product),1,fp)!=1)
{
printf("\nwrite file %s fail!End with any key\n",DataFile);
perror("Write file fail ");
getch( );
exit(1);
}
count++;
}
/*如果输入的数据量超过最大允许的范围,则提示数据不能录入*/
if (count>SIZE)
printf("\nsory,number of data can not exceed%d\n",SIZE);
fclose(fp);







/*====在屏幕上显示文件内容====*/
/* clrscr( );*/
printf("The data you input is store successful %s in file.\n",DataFile);
printf("Countent as follow:\n");


fp=fopen(DataFile,"rb");
if (fp == NULL)
{
printf("\nOpen file%sfail!End with any key \n",DataFile);
perror("Open file fail");
getch( );
exit(1);
}


printf("\nNumber\tName\tprice\tdiscountmemberprice\n");
while(fread(&TmpS,sizeof(product),1,fp) != (int)NULL)
{
printf(*\n%ld\t%s\t%4.1f\t%4.1f\t%4.1f\n",TmpS.Number,TmpS.Name,TmpS.price,TmpS.discount,Tmps.memberprice);
}


fclose(fp);
}
程序清单(5):delete.c
/*delete.c: 删除商品信息记录*/
#include "stdio.h"
void DelRecord( )
{
int i,j,k;
long delnum; /*存放顾客输入的要删除商品序号*/
product TmpS; /*定义进行操作时的临时结构体变量*/
product s[SIZE]; /*SIZE,在shead.h头文件中定义的常量,值为100*/
int recNumber; /*原文件中的记录数*/
char DataFile[40] = "",next; /*DataFile存储商品信息的文件名,next为是否进行下一次删除操作的选项*/
FILE *fp;/*====fp指针指向存储数据的文件名====*/
printf("\nplease input the name of production information file.\n");
gets(DataFile);
/*提示客户输入要进行删除记录的文件名*/
while(*DataFile == ('\0'))
{
printf("\nplease input the name of production information file.\n");
gets(DataFile);
}
begin:
/*以二进制读的方式打开文件*/
fp=fopen(DataFile,"rb");
if (fp == NULL)
{
printf("\nOpen file %s fail!End with any key\n",DataFile);
perror("Open file fail");
getch( );
exit(1);
}
/*输入要删除的商品序号*/
printf("please input the Product's seatnum which you will delete:");
scanf("%ld",&delnum);
printf("the product you will delete is:%ld\n",delnum);
/*将文件中信息存入结构体数组*/
/*与要删除的商品序号相匹配的项不写入数组,循环后数组中即为去掉了要删除记录后的剩余记录*/
recNumber=0;
while((fread(&TmpS,sizeof(product),1,fp)) != (int)NULL)
{
if(TmpS.Number!=delnum)
{
s[recNumber].Number = TmpS.Number;
strcpy(s[recNumber].Name,TmpS.Name);
s[recNumber].price = TmpS.price;
s[recNumber].discount = TmpS.discount;
s[recNumber].memberprice = TmpS.memberprice;
recNumber++;
}
}
fclose(fp);
/*====将删除后的剩余结构体记录写入文件====*/
fp=fopen(DataFile,"wb+");
if (fp == NULL)
{
printf("\nSet up file %sfail !end with angkey.\n",DataFile);
perror("Set up fail");
getch( );
exit(1);
}
for(i=0; i {
if(fwrite(&s,sizeof(product),1,fp)!=1)
{
printf("\nWrite file %s fail!end with angkey.\n",DataFile);
perror("Write file fail!");
getch( );
exit(1);
}
}
fcolse(fp);
/*====显示删除后的文件====*/
fp=fopen(DataFile,"rb");
if (fp == NULL)
{
printf("\nOpen file%sfail!End with angkey \n",DataFile);
perror("Open file fail");
getch( );
exit(1);
}
printf("the file after delete is:\n");
printf("\nNumber \t\tName\tprice\tdiscount\tmemberprice\n");
while(fread(&TmpS,sizeof(product),1,fp) != (int)NULL)
{
if(TmpS.Number!=0)


printf("\n%ld\t%s\t%4.1f\t%4.1f\t%4.1f\n",TmpS.Number,
TmpS.Name,TmpS.price,TmpS.discount,TmpS.memberprice);
}
fclose(fp);
/*询问客户是否继续删除*/
printf("\nGo on ?(y/n)");
next=getche( );
putchar('\n');
if ( next =='y' || next == 'y') goto begin;
}
程序清单(6):modnum.c
/*********************************************************************/
/* monnum.c : 修改商品信息记录 */
/********************************************************************/
#include "stdio.h"
void ModifyByNumber( )
{
int i,j,k;
long modnum; /*存储客户输入的要修改的商品序号*/
/*输入各项修改后的信息*/
long Number;
char Name[20];
float price;
float discount;
float memberprice;
product TmpS; /*定义进行操作时的临时结构体变量*/
product s[SIZE];/*SIZE,在shead.h头文件中定义的常量,值为100 */
int recNumber;
char DataFile[40] = "",next;
/*DataFile存储商品信息的文件名,next为是否进行下一次删除操作的选项*/
FILE *fp;/*====fp指针指向存储数据的文件名====*/
/*提示客户输入要进行修改记录的文件名*/
printf("\nplease input the name of file where data is stored,
end with enter key.\n");
gets(DataFile);
/*提示客户输入要进行修改记录的文件名*/
while(*DataFile == ('\0'))
{

printf("\nplease input the name of file where data is stored,
end with enter key.\n");
gets(DataFile);

}
begin:
/*以读的方式打开文件,如文件不存在,提示错误*/
fp=fopen(DataFile,"rb");
if (fp == NULL)
{
printf("\nOpen file %s fail!End with any key\n",DataFile);
perror("Open file fail");
getch( );
exit(1);
}
printf("please input the Employee'seatnum which you will modify:");
scanf("%ld",&modnum);
printf("the product you will delete is:%ld\n,modnum");
/*输入要修改记录的各项内容值*/
Number=modnum;
printf("name=");
scanf("%s",Name);

printf("price=");
scanf("%f",&price);

printf("discount=");
scanf("%f",&discount);

/*用公式自动计算商品会员价*/
memberprice=peice*discount;
/*将文件中要修改的信息存入结构体数组*/
recNumber=0;
/*循环将文件数据读入结构体数组,
如文件中的数据商品号和要修改的商品号不符,则原样写入数组,
如文件中数据的商品号和要修改商品号匹配,
则根据顾客输入的各项修改内容重新赋值,即修改,并写入数组*/
while((fread(&TmpS,sizeof (product),1,fp)) != (int)NULL)
{
if(TmpS.Number!=modnum)
{
s[recNumber].Number = TmpS.Number;
strcpy(s[recNumber].Name,TmpS.Name);
s[recNumber].price = TmpS.price;
s[recNumber].discount = TmpS.discount;
s[recNumber].memberprice = TmpS.memberprice;
recNumber++;
}
else
{
s[recNumber].Number = Number;
strcpy(s[recNumber].Name,Name);
s[recNumber].price = price;
s[recNumber].discount = discount;
s[recNumber].memberprice = memberprice;
recNumber++;
}
}
fclose(fp);
/*====将修改后的结构体数组记录写入文件====*/
fp=fopen(DataFile,"wb+");
if (fp == NULL)
{
printf("\nSet up file %sfail !end with anykey.\n",DataFile);
perror("Set up fail");
getch( );
exit(1);
}


for(i=0; i {
if(fwrite(&s,sizeof(product),1,fp)!=1)
{
printf("\nWrite file %s fail!end with anykey.\n",DataFile);
perror("Write file fail!");
getch( );
exit(1);
}
}
fclose(fp);
/*====显示修改后的文件====*/
fp=fopen(DataFile,"rb");
if (fp == NULL)
{
printf("\nOpen file%sfail!end with any key \n",DataFile);
perror("Open file fail");
getch( );
exit(1);
}
printf("the file after modify is:\n");
printf("\nNumber\t\tName\tprice\tdiscount\tmemberprice\n");
while(fread(&TmpS,sizeof(produnt),1,fp) != (int)NULL)
{
if(TmpS.Number!=0)
printf("\n%ld\t%s\t%4.1f\t%4.1f\t%4.1f\n",TmpS.Number,
TmpS.Name,TmpS.price,TmpS.discount,TmpS.memberprice);
}
fclose(fp);
/*提示是否进行下一次修改*/
printf("\nGo on ?(y/n)");
next=getche( );
putchar('\n');
if( next =='y' || next =='y') goto begin;
}
程序清单(7):qname.c
/*=======quame.c:按名称查询商品信息记录===============*/
#include "stdio.h"
void QueryByName()
(
int result=0;/*"result=1"说明查询成功,反之查找失败*/
product TmpS;/*定义进行操作时的临时结构体变量*/



char Xingming[20];/*用户输入要查询的商品名称*/
char DateFile[40] = ""、next
/*DateFile存储商品信息的文件名,next为是否进行下一次删除操作的选项*/
FILE *fp=NULL;
/*====fp指针指向存储数据的文件名====*/
/*提示用户输入要查询的文件名*/
printf("\nplease input the name of product information file .\n");
gets(DateFile);
/*提示用户输入要查询的文件名*/
while(*DateFile == ('\0'))
{
printf("\nplease input the name of product information file .\n");
gets(DateFile);
}
/*提示用户输入要查询的文件名*/
begin:
result=0;
printf("please input the name of product which needs look up (under 20 bit figure).\n");
scanf("%s".&Xingming);
getchar();
/*以读方式打开文件*/
pf=fopen (DateFile ."r");
if (fp=NULL)
{
printf("\nOpen file%sfale!Eed with any key .\n".DateFile);
perror(open file fail");
getch();
exit(1);
}
/*循环查找和输入名称相匹配的商品信息记录,如果查找到,则输出结果*/
while(feof(fp==0))
{
if(fread(&TmpS.sizeof(product).1,fp)!=(int)NULL)
(
if (stricmp(Tmps,Name,xingming)==0)
{
printf ("\n Find:)\n");
printf("\nNumber=%ld Name=%s price=%4.if discount=%4.if meberprice=%4.if\n".TmpS.Number.Name.Tmps.price.TmpS.discount.TmpS.memberprice);
result=1;/*"result=1"说明找到了该商品的对应信息.*/
}
}
}
fclose(fp);
/*提示用户已查到结果并询问是否继续查找*/
if (result == 0 )
{
printf("There is no date of this product in the file!")
}
printf("\nGo on ?(y/n)");
next=getche();
putchar('\n');
if (next=='y' || next =='y')goto begin ;
}
程序清单(8):smprice.c
/*smemberprice.c:按商品会员价循序排序*/
#include "stdio.h"
void SortByMenberPrice()
{
int i.j.k;
product Tmps; /*定义进行操作时的临时结构体变量*/
product s[SIZE];/*SIZE,在shead.h头文件中定义的常量,值为100*/
int recNnmber =0
char DateFile[40] =" "; /*DateFile存储商品信息的文件名*/
FILE *fp ;/*====fp 指针指向存储数据的文件名====*、
/*提示用户输入要进行排序的文件名*/
printf("\nplease input the name of product information file.\n");
get(DateFile);
/*提示用户输入要进行排序的文件名*/
while (DateFile == ('\0'))
{
printf("\nplease input the name of product information file.\n");
get(DateFile);
}
/*以读的方式打开文件,如果文件不存在,提示错误*/
fp =fopen(DateFile."rb");
if (fp=NULL)
{
printf("\nopen file %s fail!End with any key\n".DateFile);
perror("Open file fail ");
getch();
exit();
}
/*将文件重要排序的信息存入结构体数组*/
while ((fread(&TmpS.sizeof(product).1.fp))!=(int)NULL)
{
s[reNumber].Number= TmpS.Number;
strcpy(s[reNumber].Name.TmpS.Name);
s[reNumber].price=TmpS.price;
s[reNumber].discount=TmpS.discount;
s[reNumber].memberprice=TmpS.memberprice;
reNember++;
}
fclose(fp);
/*===如果文件中有记录,则将各条记录按合计得排序===*/
if(recNumber>1)
{
/*====用选择排序的方法进行合计得排序====*/
for(i=0;i {
k=i;
for (j=i+1;j {
if (s[k].memberprice }
TmpS .Number =s[k].Number;
strcpy(TmpS,Name.s[k].Name);
TmpS .price=s[k].price;
TmpS .discount=s=[k].discount;
TmpS .memberprice =s[k].memberprice;



s[k].Number=s.Number;
strcpy(s[k].Name.s.Name);
s[k].price=s.price;
s[k].discount=s.discount;
s[k].memberprice=s.memberprice;



s[k].Number=TmpS.Number;
strcpy(s[k].Name.TmpS.Name);
s[k].price=TmpS.price;
s[k].discount=TmpS.discount;
s[k].memberprice=TmpS.memberprice;
}
/*====将排序好的结构体记录写入文件====*/
fp=fopen(DateFile."wb+");
if(fp== NULL)
{
printf("\Set up file %sfail !end with anykey .\n".DateFile);
perror("Set up fail");
getch();
exit();
}
for(i=0;i {
if (fwrite(&s.sizeof(product).1.fp)!=1)
{
printf("\nwrite file %sfail !end with anykey .\n".DateFile);
perror("Write file fail ");
getch();
exit();
}
}
fclose(fp);
}
/*====显示排序后的文件====*/

printf("\the product's information in file %s is as flow:.\n".DateFile);
fp =fopen(DateFile."rb");
if(fp==NULL)
{
printf("\nopen file %sfail !End with anykey .\n".DateFile);
perror("Open file fail");
getch();
exit();
}
printf("\nNumber\tName\tprice\tdiscount\tmemberprice\n");
while(fread(&TmpS.sizeof(product).1.fp)!=(int)NULL)
{
printf("n%ld\t%s\t%4.2f\t%4.2f\t%4.2f\n".TmpS.Number.TmpS.Name.TmpS.price.TmpS.discount.TmpS.memberprice);
}
fclose(fp);
}
推荐阅读
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • 学习SLAM的女生,很酷
    本文介绍了学习SLAM的女生的故事,她们选择SLAM作为研究方向,面临各种学习挑战,但坚持不懈,最终获得成功。文章鼓励未来想走科研道路的女生勇敢追求自己的梦想,同时提到了一位正在英国攻读硕士学位的女生与SLAM结缘的经历。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 本文介绍了新款奇骏的两个让人上瘾的功能,分别是智能互联系统和BOSE音响。通过对新款奇骏的配置和功能进行评测,探讨了这两个新增功能的使用体验和优势。此外,还介绍了新款奇骏的其他配置和改进,如增加的座椅和驾驶辅助系统,以及内饰的舒适性提升。对于喜欢音响的消费者来说,BOSE音响的升级也是一个亮点。最后,文章提到了BOSE音响的数字还原能力,以及7座版无法配备BOSE音响的原因。 ... [详细]
  • 本文介绍了adg架构设置在企业数据治理中的应用。随着信息技术的发展,企业IT系统的快速发展使得数据成为企业业务增长的新动力,但同时也带来了数据冗余、数据难发现、效率低下、资源消耗等问题。本文讨论了企业面临的几类尖锐问题,并提出了解决方案,包括确保库表结构与系统测试版本一致、避免数据冗余、快速定位问题等。此外,本文还探讨了adg架构在大版本升级、上云服务和微服务治理方面的应用。通过本文的介绍,读者可以了解到adg架构设置的重要性及其在企业数据治理中的应用。 ... [详细]
  • 禁止程序接收鼠标事件的工具_VNC Viewer for Mac(远程桌面工具)免费版
    VNCViewerforMac是一款运行在Mac平台上的远程桌面工具,vncviewermac版可以帮助您使用Mac的键盘和鼠标来控制远程计算机,操作简 ... [详细]
  • 本文详细介绍了云服务器API接口的概念和作用,以及如何使用API接口管理云上资源和开发应用程序。通过创建实例API、调整实例配置API、关闭实例API和退还实例API等功能,可以实现云服务器的创建、配置修改和销毁等操作。对于想要学习云服务器API接口的人来说,本文提供了详细的入门指南和使用方法。如果想进一步了解相关知识或阅读更多相关文章,请关注编程笔记行业资讯频道。 ... [详细]
  • 生成对抗式网络GAN及其衍生CGAN、DCGAN、WGAN、LSGAN、BEGAN介绍
    一、GAN原理介绍学习GAN的第一篇论文当然由是IanGoodfellow于2014年发表的GenerativeAdversarialNetworks(论文下载链接arxiv:[h ... [详细]
  • 信息安全等级保护是指对国家秘密信息、法人和其他组织及公民的专有信息以及公开信息和存储、传输、处理这些信息的信息系统分等级实行安全保护,对信息系统中使用的信息安全产品实 ... [详细]
  • 无线认证设置故障排除方法及注意事项
    本文介绍了解决无线认证设置故障的方法和注意事项,包括检查无线路由器工作状态、关闭手机休眠状态下的网络设置、重启路由器、更改认证类型、恢复出厂设置和手机网络设置等。通过这些方法,可以解决无线认证设置可能出现的问题,确保无线网络正常连接和上网。同时,还提供了一些注意事项,以便用户在进行无线认证设置时能够正确操作。 ... [详细]
  • t-io 2.0.0发布-法网天眼第一版的回顾和更新说明
    本文回顾了t-io 1.x版本的工程结构和性能数据,并介绍了t-io在码云上的成绩和用户反馈。同时,还提到了@openSeLi同学发布的t-io 30W长连接并发压力测试报告。最后,详细介绍了t-io 2.0.0版本的更新内容,包括更简洁的使用方式和内置的httpsession功能。 ... [详细]
  • 本文详细介绍了相机防抖的设置方法和使用技巧,包括索尼防抖设置、VR和Stabilizer档位的选择、机身菜单设置等。同时解释了相机防抖的原理,包括电子防抖和光学防抖的区别,以及它们对画质细节的影响。此外,还提到了一些运动相机的防抖方法,如大疆的Osmo Action的Rock Steady技术。通过本文,你将更好地理解相机防抖的重要性和使用技巧,提高拍摄体验。 ... [详细]
  • 本文详细介绍了华为4GLTE路由器B310的外置天线安装和设置方法。通过连接电源和网线,输入路由器的IP并登陆设置页面,选择手动设置和手动因特网设置,输入ISP提供商的用户名和密码,并设置MTU值。同时,还介绍了无线加密的设置方法。最后,将外网线连在路由器的WAN口即可使用。 ... [详细]
  • 本文讨论了前端工程化的准备工作,主要包括性能优化、安全防护和监控等方面需要注意的事项。通过系统的答案,帮助前端开发者更好地进行工程化的准备工作,提升网站的性能、安全性和监控能力。 ... [详细]
author-avatar
无极圈晨曦
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有