我这有一简单的C语言程序,是在WIN-TC中运行的,那位大哥能帮忙改成VC6运行的啊,会的+QQ771720658
http://hi.baidu.com/shaoqingtan/blog/item/cb34151a3a6010fa1ad576e0.html你看看吧程序在这里...
http://hi.baidu.com/shaoqingtan/blog/item/cb34151a3a6010fa1ad576e0.html 你看看吧 程序在这里
展开
2010-08-30
展开全部
修改如下,主要是去掉了一些头文件包含(没有必要的包含)以及主函数中开头部分设置输出格式的部分,其它部分未改动:
#include "stdio.h" /*I/O函数*/
#include "stdlib.h" /*其它说明*/
#include "string.h" /*字符串函数*/
#include "conio.h" /*屏幕操作函数*/
#include <windows.h>
#include "ctype.h" /*字符操作函数*/
struct money
{
char kahao[8];
char mingzi[20];
float money[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;
void shuru()
{
if((fp=fopen("s_money.txt","ab+"))==NULL)
{
printf("cannot open this file.\n");
getch();exit(0);
}
for(i=0;i<=1000;i++)
{
printf("\n请输入卡号:");
gets(data.kahao);
printf("请输入姓名:");
gets(data.mingzi);
printf("请输入存款金额(1):");
gets(temp);data.money[0]=atof(temp);
printf("请输入存款金额(2):");
gets(temp);data.money[1]=atof(temp);
printf("请输入存款金额(3):");
gets(temp);data.money[2]=atof(temp);
printf("请输入存款金额(4):");
gets(temp);data.money[3]=atof(temp);
printf("请输入存款金额(5):");
gets(temp);data.money[4]=atof(temp);
data.money[5]=data.money[0]+data.money[1]+data.money[2]+data.money[3]+data.money[4];
fwrite(&data,sizeof(data),1,fp);
printf("继续?y/n");
ch=getch();
if(ch=='n'||ch=='N')
break;
} fclose(fp);
}
void xianshi()
{
float s;int n;
if((fp=fopen("s_money.txt","rb+"))==NULL)
{
printf("Cannot reading this file.\n");
exit(0);
}
for(i=0;i<=1000;i++)
{
if((fread(&info[i],sizeof(info[i]),1,fp))!=1)
break;
}
printf("\nkahao mingzi cunkuan1 cunkuan2 cunkuan3 cunkuan4 cunkuan5 money\n");
for(j=0,k=1;j<i;j++,k++)
{
printf("%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n",info[j].kahao,info[j].mingzi,info[j].money[0],info[j].money[1],info[j].money[2],info[j].money[3],info[j].money[4],
info[j].money[5]);
}
getch();
fclose(fp);
}
void xiugai()
{
if((fp=fopen("s_money.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("Cannot open this file.\n");
exit(0);
}
printf("\n请输入要进行修改的卡号:");
scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.kahao);
if(j==i)
{
printf("kahao:%s\nmingzi:%s\n",data.kahao,data.mingzi);
printf("请输入姓名:");
gets(data.mingzi);
printf("请输入存款金额(1):");
gets(temp);data.money[0]=atof(temp);
printf("请输入存款金额(2):");
gets(temp);data.money[1]=atof(temp);
printf("请输入存款金额(3):");
gets(temp);data.money[2]=atof(temp);
printf("请输入存款金额(4):");
gets(temp);data.money[3]=atof(temp);
printf("请输入存款金额(5):");
gets(temp);data.money[4]=atof(temp);
data.money[5]=data.money[0]+data.money[1]+data.money[2]+data.money[3]+data.money[4];
} fwrite(&data,sizeof(data),1,fp1);
}
fseek(fp,0L,0);
fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1)
{
fwrite(&data,sizeof(data),1,fp);
}
fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_money.txt","rb"))==NULL)
{
printf("\nCannot open this file.\n");
exit(0);
}
printf("\n请输入要查找的卡号:");
scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1)
{
j=atoi(data.kahao);
if(i==j)
{
printf("kahao:%s mingzi:%s\ncunkuan1:%f\n cunkuan2:%f\n cunkuan3:%f\n cunkuan4:%f\n cunkuan5:%f\n ",data.kahao,data.mingzi,data.money[0],data.money[1],data.money[2],data.money[3],data.money[4],data.money[5]);
}getch();
}
}
void shanchu()
{
if((fp=fopen("s_money.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("\nopen money.txt was failed!");
getch();
exit(0);
}
printf("\n请输入您想删除的卡号:");
scanf("%d",&i);getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.kahao);
if(j==i)
{
printf("按任意键以删除!\n");
getch();
continue;
}
fwrite(&data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove("s_money.txt");
rename("temp.txt","s_money.txt");
printf("删除成功!\n");
printf("按任意键返回主菜单!");
getch();
}
main()
{
COORD pos;
pos.X=pos.Y=1;/*设置光标位置*/
while(1)
{
system("cls"); /*清屏幕*/
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); /*移动光标*/
system("color 16"); /*设置背景颜色为蓝色,文本显示颜色为黄色*/
system("cls");
printf("***************欢迎您使用信用卡管理系统**********************\n");
printf("*************************菜单********************************\n");
printf("* ========================================================= * \n");
printf("* 1>输入 2>修改 * \n");
printf("* 3>删除 4>查找 * \n");
printf("* 5>显示 6>退出 * \n");
printf("* * \n");
printf("* --------------------------------------------------------- * \n");
printf(" 请输入您想进行的操作(1-6):");
ch=getch();
switch(ch)
{
case '1':shuru();break;
case '2':xiugai(); break;
case '3':shanchu(); break;
case '4':chazhao(); break;
case '5':xianshi(); break;
case '6':exit(0);
default: continue;
}
}
}
#include "stdio.h" /*I/O函数*/
#include "stdlib.h" /*其它说明*/
#include "string.h" /*字符串函数*/
#include "conio.h" /*屏幕操作函数*/
#include <windows.h>
#include "ctype.h" /*字符操作函数*/
struct money
{
char kahao[8];
char mingzi[20];
float money[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;
void shuru()
{
if((fp=fopen("s_money.txt","ab+"))==NULL)
{
printf("cannot open this file.\n");
getch();exit(0);
}
for(i=0;i<=1000;i++)
{
printf("\n请输入卡号:");
gets(data.kahao);
printf("请输入姓名:");
gets(data.mingzi);
printf("请输入存款金额(1):");
gets(temp);data.money[0]=atof(temp);
printf("请输入存款金额(2):");
gets(temp);data.money[1]=atof(temp);
printf("请输入存款金额(3):");
gets(temp);data.money[2]=atof(temp);
printf("请输入存款金额(4):");
gets(temp);data.money[3]=atof(temp);
printf("请输入存款金额(5):");
gets(temp);data.money[4]=atof(temp);
data.money[5]=data.money[0]+data.money[1]+data.money[2]+data.money[3]+data.money[4];
fwrite(&data,sizeof(data),1,fp);
printf("继续?y/n");
ch=getch();
if(ch=='n'||ch=='N')
break;
} fclose(fp);
}
void xianshi()
{
float s;int n;
if((fp=fopen("s_money.txt","rb+"))==NULL)
{
printf("Cannot reading this file.\n");
exit(0);
}
for(i=0;i<=1000;i++)
{
if((fread(&info[i],sizeof(info[i]),1,fp))!=1)
break;
}
printf("\nkahao mingzi cunkuan1 cunkuan2 cunkuan3 cunkuan4 cunkuan5 money\n");
for(j=0,k=1;j<i;j++,k++)
{
printf("%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n",info[j].kahao,info[j].mingzi,info[j].money[0],info[j].money[1],info[j].money[2],info[j].money[3],info[j].money[4],
info[j].money[5]);
}
getch();
fclose(fp);
}
void xiugai()
{
if((fp=fopen("s_money.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("Cannot open this file.\n");
exit(0);
}
printf("\n请输入要进行修改的卡号:");
scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.kahao);
if(j==i)
{
printf("kahao:%s\nmingzi:%s\n",data.kahao,data.mingzi);
printf("请输入姓名:");
gets(data.mingzi);
printf("请输入存款金额(1):");
gets(temp);data.money[0]=atof(temp);
printf("请输入存款金额(2):");
gets(temp);data.money[1]=atof(temp);
printf("请输入存款金额(3):");
gets(temp);data.money[2]=atof(temp);
printf("请输入存款金额(4):");
gets(temp);data.money[3]=atof(temp);
printf("请输入存款金额(5):");
gets(temp);data.money[4]=atof(temp);
data.money[5]=data.money[0]+data.money[1]+data.money[2]+data.money[3]+data.money[4];
} fwrite(&data,sizeof(data),1,fp1);
}
fseek(fp,0L,0);
fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1)
{
fwrite(&data,sizeof(data),1,fp);
}
fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_money.txt","rb"))==NULL)
{
printf("\nCannot open this file.\n");
exit(0);
}
printf("\n请输入要查找的卡号:");
scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1)
{
j=atoi(data.kahao);
if(i==j)
{
printf("kahao:%s mingzi:%s\ncunkuan1:%f\n cunkuan2:%f\n cunkuan3:%f\n cunkuan4:%f\n cunkuan5:%f\n ",data.kahao,data.mingzi,data.money[0],data.money[1],data.money[2],data.money[3],data.money[4],data.money[5]);
}getch();
}
}
void shanchu()
{
if((fp=fopen("s_money.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("\nopen money.txt was failed!");
getch();
exit(0);
}
printf("\n请输入您想删除的卡号:");
scanf("%d",&i);getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.kahao);
if(j==i)
{
printf("按任意键以删除!\n");
getch();
continue;
}
fwrite(&data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove("s_money.txt");
rename("temp.txt","s_money.txt");
printf("删除成功!\n");
printf("按任意键返回主菜单!");
getch();
}
main()
{
COORD pos;
pos.X=pos.Y=1;/*设置光标位置*/
while(1)
{
system("cls"); /*清屏幕*/
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); /*移动光标*/
system("color 16"); /*设置背景颜色为蓝色,文本显示颜色为黄色*/
system("cls");
printf("***************欢迎您使用信用卡管理系统**********************\n");
printf("*************************菜单********************************\n");
printf("* ========================================================= * \n");
printf("* 1>输入 2>修改 * \n");
printf("* 3>删除 4>查找 * \n");
printf("* 5>显示 6>退出 * \n");
printf("* * \n");
printf("* --------------------------------------------------------- * \n");
printf(" 请输入您想进行的操作(1-6):");
ch=getch();
switch(ch)
{
case '1':shuru();break;
case '2':xiugai(); break;
case '3':shanchu(); break;
case '4':chazhao(); break;
case '5':xianshi(); break;
case '6':exit(0);
default: continue;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询