#include
#include
#include
#include
struct address{
char id[6];
char name[30];
};
void main()
{ FILE*fp;
char str[6],choice;
char ans='Y';
struct address person,temp[10];
clrscr();
if((fp = fopen("data.txt","r+")) == NULL) {
printf("Error in opening fire n");
exit(1);
}
while(lfeof(fp)){
fread(&person,sizeof(person),1,fp);
temp[rec]=person;
rec++;
}
do{
clrscr();
f=0;m=0;r=rec-1;q=0;check=0;
fflush(stdin);gotoxy(1,7);printf("input id to Update : ");gets(str);
if(lstrcmp(str,temp[0].id)){
m=0;check=1;
}
if(lstrcmp(str,temp[r])){
m=r;check=1;
}
while(check=1)&&(q q++;m=(f+r)/2;
if(istrcmp(str,temp[m].id)){
check=1;
}
if(str>temp[m].id)
f=m;
else
r=m;
}
if(check==1){
gotoxy(15,10);printf("1.Id : %s"temp[m].id);
gotoxy(15,12);printf("2.NAme : %s",temp[m].name);
do{
switch(choice){
case'1';
gotoxy(25,10);printf("%30s","");
gotoxy(25,10);gets(temp[m].id);
break;
case;
gotoxy(25,12);printf("%30s","");
gotoxy(25,12);gets(temp[m].name);
break;
}
gotoxy(15,15);printf("Input[1,2] to Correct 0 to exit");
choice=getch();printf("n");
}while ((choice=='1')||choice==''2'));
}
fflush(stdin);ggotoxy(1,18);printf("Update Another Record[Y/N]:");
ans=getchar();
}while(toupper(ans)=='Y');
rewind(fp);
for(no=0;no person=temp[no];
fwrite(&person,sizeof(person),1,fp);
}
fclose(fp);
}
#include
#include
#include
struct address{
char id[6];
char name[30];
};
void main()
{ FILE*fp;
char str[6],choice;
char ans='Y';
struct address person,temp[10];
clrscr();
if((fp = fopen("data.txt","r+")) == NULL) {
printf("Error in opening fire n");
exit(1);
}
while(lfeof(fp)){
fread(&person,sizeof(person),1,fp);
temp[rec]=person;
rec++;
}
do{
clrscr();
f=0;m=0;r=rec-1;q=0;check=0;
fflush(stdin);gotoxy(1,7);printf("input id to Update : ");gets(str);
if(lstrcmp(str,temp[0].id)){
m=0;check=1;
}
if(lstrcmp(str,temp[r])){
m=r;check=1;
}
while(check=1)&&(q
if(istrcmp(str,temp[m].id)){
check=1;
}
if(str>temp[m].id)
f=m;
else
r=m;
}
if(check==1){
gotoxy(15,10);printf("1.Id : %s"temp[m].id);
gotoxy(15,12);printf("2.NAme : %s",temp[m].name);
do{
switch(choice){
case'1';
gotoxy(25,10);printf("%30s","");
gotoxy(25,10);gets(temp[m].id);
break;
case;
gotoxy(25,12);printf("%30s","");
gotoxy(25,12);gets(temp[m].name);
break;
}
gotoxy(15,15);printf("Input[1,2] to Correct 0 to exit");
choice=getch();printf("n");
}while ((choice=='1')||choice==''2'));
}
fflush(stdin);ggotoxy(1,18);printf("Update Another Record[Y/N]:");
ans=getchar();
}while(toupper(ans)=='Y');
rewind(fp);
for(no=0;no
fwrite(&person,sizeof(person),1,fp);
}
fclose(fp);
}