这个程序谁帮我看看?没有错误,但是目的达不到
#include "stdafx.h"#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define N 10000
char sj[9][N];
int bh1;
int chuangjian();
void shanchu();
int chuangjian()
{
char c='n';
int i=0,bh1=0;
FILE*fb;
if((fb=fopen("人事.txt","wb+"))==NULL)
{
printf("can't open file\n");
exit(1);
}
while(c=='N'||c=='n')
{
printf("请根据提示输入信息\n");
printf("编号\n");
scanf("%s,%s\n",&sj[0][bh1]); getchar();
printf("姓名\n");
scanf("%s,%s\n",&sj[1][bh1]); getchar();
printf("性别\n");
scanf("%s,%s\n",&sj[2][bh1]); getchar();
printf("出生年份\n");
scanf("%s,%s\n",&sj[3][bh1]); getchar();
printf("参加工作年份\n");
scanf("%s,%s\n",&sj[4][bh1]); getchar();
printf("工资\n");
scanf("%s,%s\n",&sj[5][bh1]); getchar();
printf("学院\n");
scanf("%s,%s\n",&sj[6][bh1]); getchar();
printf("职务\n");
scanf("%s,%s\n",&sj[7][bh1]); getchar();
printf("学位\n");
scanf("%s,%s\n",&sj[8][bh1]); getchar();
for(i=0;i<9;i++)
fwrite(&sj[i][bh1],10,1,fb);
bh1++;
printf("是否返回(Y/N)\n");
scanf("%c",&c);
}
fclose(fb);
return(sj[0][bh1]);
}
void shanchu()
{
char c='Y',m='Y',bh2;
int i=0,j=0,k=0,bh1;
FILE*fb;
if((fb=fopen("人事.txt","rb+"))==NULL)
{
printf("can't open file\n");
exit(1);
}
while(c=='Y'||c=='y')
{
printf("请输入被删除老师的编号:");
scanf("%c",&bh2);
getchar();
printf("确定删除么?(Y/N)");
m=getchar(); getchar();
if(m=='Y'||m=='y')
for(i=0;i<bh1;i++)
if(sj[0][i]==bh2)
{
k=i;
break;
}
if(k<0)
printf("输入有误\n");
for(i=k;i<bh1;i++)
for(j=0;j<9;j++)
sj[j][i]=sj[j][i+1];
for(i=0;i<9;i++)
for(j=0;j<bh1;j++)
fwrite(&sj[i][j],10,1,fb);
bh1=bh1-1;
printf("是否继续删除?(Y/N):");
c=getchar();
}
}
void main()
{
while(1)
{
int q;
printf("\n");
printf("\t*************2.删除****************\n");
printf("\t*************3.创建****************\n");
printf("\t**********5.退出***********\n");
scanf("%d",&q);
switch(q)
{
case 2:shanchu();break;
case 3:chuangjian();break;
case 5:printf("谢谢使用,88\n");exit(1);
default:printf("输入错误,请重新选择!\n");
}
}
}删除没法成功