ข่าวสารทางเว็บ : เปิดสมัครสมาชิกใหม่แล้วนะครับ แต่ต้อง Login ด้วย facebook ก่อน
หน้า: [1]   ลงล่าง
  ส่งหัวข้อนี้  |  พิมพ์  
ผู้เขียน หัวข้อ: ช่วยแก้ให้หน่อยคับ คอมไพไม่ผ่านอะคับหาที่แก้ไม่เจอ  (อ่าน 1066 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
vampiresk
Baby - C
*

Thank : 0 
ออฟไลน์ ออฟไลน์

กระทู้: 1



« เมื่อ: กันยายน 21, 2010, 02:26:57 pm »

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
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<rec/3)) {
      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<rec-1;no++){
   person=temp[no];
   fwrite(&person,sizeof(person),1,fp);
  }
  fclose(fp);
  }
   

ถูกใจบทความนี้กดเลย >>
บันทึกการเข้า
Moshi
พนักงาน it4x
Pro - A
*

Thank : 26 
ออฟไลน์ ออฟไลน์

กระทู้: 13690



เว็บไซต์
« ตอบ #1 เมื่อ: กันยายน 21, 2010, 07:58:18 pm »

เดียวพรุ่งนี้ดูให้นะครับ
บันทึกการเข้า
งานออนไลน์
หน้า: [1]   ขึ้นบน
  ส่งหัวข้อนี้  |  พิมพ์  
 
กระโดดไป:  

พื้นที่สนทนาภายในเว็บ it4x.com (เอาไว้คุยกันครับ)
ถูกใจเว็บ it4x.com กด Like เลย
Powered by MySQL Powered by PHP Powered by SMF 1.1.14 | SMF © 2006-2009, Simple Machines LLC | Sitemap Valid XHTML 1.0! Valid CSS!
eXTReMe Tracker
พฤษภาคม 23, 2012, 09:40:19 am
เวลาปัจจุบัน