ข่าว IT ล่าสุด
ถูกใจอย่าลืม Like Fanpage
ช่วยแก้ให้หน่อยคับ คอมไพไม่ผ่านอะคับหาที่แก้ไม่เจอ
แสดงแล้ว 5299 ครั้ง /
กันยายน 21, 2010, 14:26:57

vampiresk

ออฟไลน์
กระทู้ : 1
คะแนนขอบคุณ : 0
#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);
  }
   


Moshi

ออฟไลน์
กระทู้ : 16,996
คะแนนขอบคุณ : 45
it4x สังคมแห่งการเรียนรู้
กันยายน 21, 2010, 19:58:18
เดียวพรุ่งนี้ดูให้นะครับ

 

ด้วยฟังค์ชั่น ตอบด่วน คุณสามารถใช้โค๊ดและ เครื่องหมายแสดงอารมณ์ได้ เหมือนการตั้งกระทู้ธรรมดา แต่สามารถทำได้สะดวกกว่า

ระวัง: หัวข้อนี้ไม่มีการอัพเดทมานานถึง 120 วัน

แจ้งเตือน: โพสของคุณจะไม่แสดงจนกว่าผู้ดูแลจะอนุมัติ.
ชื่อ: อีเมล์: