HOW to convert this coding to DEV c++ 4.9.9.2

Discussion in 'C Programming' started by melisa, Jan 16, 2011.

  1. melisa

    melisa

    Joined:
    Jan 11, 2011
    Messages:
    3
    hi....I m just a beginner.
    Could someone help me,please?I've tried learning before, but dev c++ 4.9.9.2 use different syntax than turbo c++ :banghead:
    I was wondering to try this coding on dev c++ 4.9.9.2

    here is the program I am trying to write in turbo c++ , Could anyone check and fix it for me please....?? :frown:

    Code:
    #include<conio.h>
    #include<io.h>
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    
    menu();
    add();
    change();
    display();
    del();
    search();
    
    
    struct data_borrower
    {
      char codecd[5];
      char typecd[15];
      char borrower[15];
      char address[15];
      char telepon[10];
    } data,data2;
    
    
    FILE *fp1;
    FILE *fp;
    
    main()
    {
      char pilih='0';
    
      while(pilih!='7')
      {
         menu();
         gotoxy(33,23);scanf("%c",&pilih);
         switch(pilih)
         {
            case '1' :
              if((fp=fopen("\\filedata.txt","w"))==NULL)
              {
    
                 gotoxy(20,25);printf("File Data can't open!");
                 gotoxy(20,26);printf("make a nwe file!");
                 gotoxy(20,27);printf("Program stop.");
                 getche();
                 exit(1);
              }
              add();
              fclose(fp);
              break;
            case '2' :
              if((fp=fopen("\\filedata.txt","a+"))==NULL)
              {
    
                 gotoxy(20,25);printf("File Data can't open!");
                 gotoxy(20,26);printf("make a nwe file!");
                 gotoxy(20,27);printf("Program stop.");
                 getche();
                 exit(1);
              }
              add();
              fclose(fp);
              break;
            case '3' :
              if((fp=fopen("\\filedata.txt","r+"))==NULL)
              {
    
                 gotoxy(20,25);printf("File Data can't open!");
                 gotoxy(20,26);printf("make a nwe file!");
                 gotoxy(20,27);printf("Program stop.");
                 getche();
                 exit(1);
              }
              change();
              fclose(fp);
              break;
            case '4' :
              if((fp=fopen("\\filedata.txt","r"))==NULL)
              {
    
                 gotoxy(20,25);printf("File Data can't open!");
                 gotoxy(20,26);printf("make a nwe file!");
                 gotoxy(20,27);printf("Program stop.");
                 getche();
                 exit(1);
              }
              display();
              fclose(fp);
              break;
            case '5' :
              if((fp=fopen("\\filedata.txt","r+"))==NULL)
              {
    
                 gotoxy(20,25);printf("File Data can't open!");
                 gotoxy(20,26);printf("make a nwe file!");
                 gotoxy(20,27);printf("Program stop.");
                 getche();
                 exit(1);
              }
              del();
              fclose(fp);
              break;
            case '6' :
    
              if((fp=fopen("\\filedata.txt","r"))==NULL)
              {
    
                 gotoxy(20,25);printf("File Data can't open!");
                 gotoxy(20,26);printf("make a nwe file!");
                 gotoxy(20,27);printf("Program stop.");
                 getche();
                 exit(1);
              }
              search();
              getch();
              break;
            case '7':
              break;
         }
      }
      return(0);
    }
    menu()
    {
      clrscr();
    
    
      gotoxy(20,8);printf ("               M  E  N  U         ");
    
      gotoxy(20,9);printf("___________________________________________");
    
      gotoxy(20,12);printf("        [ 1 ]  MAKE NEW DATA.      ");
      gotoxy(20,13);printf("        [ 2 ]  ADD DATA.          ");
      gotoxy(20,14);printf("        [ 3 ]  CHANGE  DATA.           ");
      gotoxy(20,15);printf("        [ 4 ]  SHOW DATA.       ");
      gotoxy(20,16);printf("        [ 5 ]  DELETE DATA.       ");
      gotoxy(20,17);printf("        [ 6 ]  SEARCH                ");
      gotoxy(20,18);printf("        [ 7 ]  FINISH.                ");
      gotoxy(20,21);printf("___________________________________________");
    
      gotoxy(20,23);printf(" choice =  [   ]");
    
      return 0;
    }
    add()
    {
      clrscr();
    
      gotoxy(20,7);printf("_____________________________________________");
    
      gotoxy(20,9); printf(" CODE   ($-stop) : ");
      gotoxy(20,10);printf(" TYPE CD        : ");
      gotoxy(20,11);printf(" BORROWER        : ");
      gotoxy(20,12);printf(" ADDRESS          : ");
      gotoxy(20,13);printf(" TELEPON         : ");
    
      gotoxy(20,14);printf("_____________________________________________");
      gotoxy(39,9);scanf("%s",&data.codecd);
      while(data.codecd[0]!='$')
      {
         gotoxy(39,10);scanf("%s",&data.typecd);
         gotoxy(39,11);scanf("%s",&data.borrower);
         gotoxy(39,12);scanf("%s",&data.address);
         gotoxy(39,13);scanf("%s",&data.telepon);
    
         fwrite(&data,sizeof(data),1,fp);
         clrscr();
    
         gotoxy(20,7);printf("_____________________________________________");
    
         gotoxy(20,9); printf(" CODE   ($-stop) : ");
         gotoxy(20,10);printf(" TYPE CD        : ");
         gotoxy(20,11);printf(" BORROWER        : ");
         gotoxy(20,12);printf(" ADDRESS          : ");
         gotoxy(20,13);printf(" TELEPON         : ");
    
         gotoxy(20,14);printf("_____________________________________________");
         gotoxy(39,9);scanf("%s",&data.codecd);
      }
      return 0;
    }
    change()
    {
      int nomor;
      long int offset;
      clrscr();
    
      gotoxy(20,9);printf("OLD DATA");
    
      gotoxy(19,10);printf("_____________________________________________");
    
      gotoxy(20,12);printf("CODE       : ");
      gotoxy(20,13);printf("TYPE CD   : ");
      gotoxy(20,14);printf("BORROWER   : ");
      gotoxy(20,15);printf("ADDRESS     : ");
      gotoxy(20,16);printf("TELEPON    : ");
    
      gotoxy(20,18);printf("DATA BARU");
    
      gotoxy(19,19);printf("_____________________________________________");
    
      gotoxy(20,21);printf("CODE       : ");
      gotoxy(20,22);printf("TYPE CD   : ");
      gotoxy(20,23);printf("BORROWER   : ");
      gotoxy(20,24);printf("ADDRESS    : ");
      gotoxy(20,25);printf("TELEPON    : ");
    
      gotoxy(20,6);printf("NUM RECORD TO CHANGE: ");
      scanf("%d",&nomor);
      offset=(nomor-1)*sizeof(data);
      if(fseek(fp,offset,0)!=0)
      {
    
         gotoxy(20,7);printf("CAN'T SEARCH NUM RECORD  !");
         getche();
         return 0;
      }
      fread(&data,sizeof(data),1,fp);
    
      gotoxy(33,12);printf("%s",strupr(data.codecd));
      gotoxy(33,13);printf("%s",strupr(data.typecd));
      gotoxy(33,14);printf("%s",strupr(data.borrower));
      gotoxy(33,15);printf("%s",strupr(data.address));
      gotoxy(33,16);printf("%s",strupr(data.telepon));
    
      gotoxy(33,21);scanf("%s",data.codecd);
      gotoxy(33,22);scanf("%s",data.typecd);
      gotoxy(33,23);scanf("%s",data.borrower);
      gotoxy(33,24);scanf("%s",data.address);
      gotoxy(33,25);scanf("%s",data.telepon);
    
      fseek(fp,offset,0);
      fwrite(&data,sizeof(data),1,fp);
      return 0;
    }
    del()
    {
      int nomor;
      long int offset;
      clrscr();
    
      gotoxy(20,9);printf("DATA TO DIDELETE");
    
      gotoxy(19,10);printf("_____________________________________________");
    
      gotoxy(20,12);printf("CODE       : ");
      gotoxy(20,13);printf("TYPE CD   : ");
      gotoxy(20,14);printf("BORROWER   : ");
      gotoxy(20,15);printf("ADDRESS     : ");
      gotoxy(20,16);printf("TELEPON    : ");
    
    
      gotoxy(20,6);printf("NOMOR RECORD TO DIDELETE : ");
      scanf("%d",&nomor);
      offset=(nomor-1)*sizeof(data);
    
      if(fseek(fp,offset,0)!=0)
      {
    
         gotoxy(20,7);printf("CAN'T SEARCH NUM RECORD  !");
         getche();
         return 0;
      }
      fread(&data,sizeof(data),1,fp);
    
      gotoxy(33,12);printf("%s",strupr(data.codecd));
      gotoxy(33,13);printf("%s",strupr(data.typecd));
      gotoxy(33,14);printf("%s",strupr(data.borrower));
      gotoxy(33,15);printf("%s",strupr(data.address));
      gotoxy(33,16);printf("%s",strupr(data.telepon));
      fclose(fp);
      if((fp=fopen("\\filedata.txt","r"))==NULL)
      {
      }
    
      if((fp1=fopen("\\tempfiledata.txt","w"))==NULL)
      {
        gotoxy(20,27);printf("Stop.");
        getche();
        exit(1);
      }
      int i=1;
      while(fread(&data,sizeof(data),1,fp)==1)
      {
         if (i!=nomor)
         {
         data2=data;
      fwrite(&data2,sizeof(data2),1,fp1);}
      i++;
      }
      fclose(fp1);
      fclose(fp);
      remove("\\filedata.txt");
      rename("\\tempfiledata.txt","\\filedata.txt");
      return 0;
    }
    display()
    {
      int i=1;
      clrscr();
    
      gotoxy(5,5);printf("                       LIST BORROWER CD BACKUP");
    
      gotoxy(5,6);printf("_________________________________________________________________________");
    
      gotoxy(5,8);printf("  No. CODE       TYPE CD        BORROWER        ADDRESS         TELEPON  ");
    
      gotoxy(5,9);printf("_________________________________________________________________________");
    
      while(fread(&data,sizeof(data),1,fp)==1)
      {
         gotoxy(6,10+i);printf("%3d.",i++);
         gotoxy(11,9+i);printf("%-5s",strupr(data.codecd));
         gotoxy(22,9+i);printf("%-15s",strupr(data.typecd));
         gotoxy(38,9+i);printf("%-15s",strupr(data.borrower));
         gotoxy(54,9+i);printf("%-15s",strupr(data.address));
         gotoxy(65,9+i);printf("%-10s",strupr(data.telepon));
      }
    
      gotoxy(5,10+i);printf("_________________________________________________________________________");
    
      gotoxy(5,12+i);printf("  ENTER !");
    
      getche();
      return 0;
    }
    search()
    {
      int i=1;
      clrscr();
      char kode1[5];
      printf(" Enter Code");scanf("%s",&kode1);
      gotoxy(5,9);printf("_________________________________________________________________________");
    
      while(fread(&data,sizeof(data),1,fp)==1)
      {
         if (strncmp(kode1,data.codecd,4)==0)
         {
         gotoxy(11,9+i);printf("%-5s",strupr(data.codecd));
         gotoxy(22,9+i);printf("%-15s",strupr(data.typecd));
         gotoxy(38,9+i);printf("%-15s",strupr(data.borrower));
         gotoxy(54,9+i);printf("%-15s",strupr(data.address));
         gotoxy(65,9+i);printf("%-10s",strupr(data.telepon));
         }
      }
    
      gotoxy(5,10+i);printf("_________________________________________________________________________");
    
      gotoxy(5,12+i);printf("  ENTER !");
    
      getche();
      return 0;
    }
     
    melisa, Jan 16, 2011
    #1
    1. Advertising

  2. melisa

    melisa

    Joined:
    Jan 11, 2011
    Messages:
    3
    Could anyone check and fix it for me please....??
     
    melisa, Jan 17, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. calmar
    Replies:
    11
    Views:
    959
    calmar
    Feb 21, 2006
  2. Ron Peterson

    /dev/urandom vs. /dev/random

    Ron Peterson, Jan 7, 2005, in forum: C Programming
    Replies:
    21
    Views:
    1,607
    Keith Thompson
    Jan 13, 2005
  3. AC
    Replies:
    0
    Views:
    191
  4. Guest
    Replies:
    2
    Views:
    167
    Bob Barrows [MVP]
    Sep 18, 2005
  5. Eirikur Hallgrimsson
    Replies:
    3
    Views:
    181
    Gavin Sinclair
    Oct 10, 2004
Loading...

Share This Page