#include<stdio.h><br />    #include<conio.h><br />    #include<dos.h><br />    #include<string.h><br />    void main()<br />    {<br />    int iCh1,iInc;<br />    e:<br />    clrscr();<br />    /* To Display Main menu */<br />    gotoxy(26,40);<br />    textcolor(9);<br />    cprintf(\"
SOFTWARE ENGINEERING PROJECT\"
);<br />    gotoxy(32,44);<br />    textcolor(19);<br />    cprintf(\"
BATCH-1(2006-07)\"
);<br />    gotoxy(23,42);<br />    cprintf(\"
ZOO MANAGEMENT SYSTEM ( ZMS-2007)\"
);<br />    gotoxy(8,45);<br />    textcolor(9);<br />    /* To Dispaly date and time */<br />    cprintf(\"
DATE : %s \"
,__DATE__);<br />    gotoxy(55,45);<br />    cprintf(\"
TIME : %s \"
,__TIME__);<br />    for(iInc=0;iInc<=30;iInc++)<br />    {<br />    gotoxy(20,iInc);<br />    textcolor(7);<br />    cprintf(\"
-\"
);<br />    }<br />    for(iInc=0;iInc<80;iInc++)<br />    {<br />    gotoxy(iInc,30);<br />    textcolor(7);<br />    cprintf(\"
|\"
);<br />    }<br />    gotoxy(30,8);<br />    textcolor(9);<br />    /* Main menu */<br />    cprintf(\"
ZOO MANAGEMENT SYSTEM (ZMS-2007)\"
);<br />    gotoxy(30,10);<br />    textcolor(19);<br />    cprintf(\"
1.ANIMAL\"
);<br />    gotoxy(30,12);<br />    cprintf(\"
2.BIRD\"
);<br />    gotoxy(30,14);<br />    cprintf(\"
3.EXIT\"
);<br />    gotoxy(30,18);<br />    textcolor(9);<br />    cprintf(\"
ENTER YOUR CHOICE:\"
);<br />    scanf(\"
%d\"
,&iCh1);<br />    if<br />    (iCh1==3)<br />    {<br />    /* To exit from the system */<br />    gotoxy(30,28);<br />    textcolor(4);<br />    cprintf(\"
SYSTEM SHUTTING DOWN\"
);<br />    sleep(3);<br />    gotoxy(26,40);<br />    printf(\"
SOFTWARE ENGINEERING PROJECT\"
);<br />    gotoxy(8,42);<br />    printf(\"
ZOO MANAGEMENT SYSTEM ( ZMS-2007)\"
);<br />    gotoxy(8,45);<br />    printf(\"
DATE : %s \"
,__DATE__);<br />    gotoxy(55,45);<br />    printf(\"
TIME : %s \"
,__TIME__);<br />    exit(0);<br />    }<br />    else{<br />    /* Declarations of Variables */<br />    FILE *fp,*ft;<br />    char cAns,cChoice;<br />    struct zoo<br />    {<br />    char offspr[2],anim_history[50],an_name[30],keeper_nm[20],cellid[4],an_sex[2];<br />    int anim_age,offno;<br />    float wt,offrat,inbreed,food_s,food_c;<br />    };<br />    struct zoo e;<br />    char cell_id[4];<br />    int iF=0,iC=0,iF1=0;<br />    long int lRecsize;<br />    fp=fopen(\"
zm.dat\"
,\"
rb+\"
);<br />    if(fp==NULL)<br />    {<br />    fp=fopen(\"
\zm.dat\"
,\"
wb+\"
);<br />    if(fp==NULL)<br />    {<br />    puts(\"
\n\t\tCannot Open file\"
);<br />    exit();<br />    }<br />    }<br />    lRecsize=sizeof(e);<br />    while(1)<br />    {<br />    clrscr();<br />    textcolor(4);<br />    if(iCh1==1) {<br />    gotoxy(30,8);<br />    textcolor(4);<br />    cprintf(\"
ANIMAL MENU\"
); }<br />    else if(iCh1==2) {<br />    gotoxy(30,8);<br />    textcolor(4);<br />    cprintf(\"
BIRD MENU\"
); }<br />    gotoxy(26,40);<br />    textcolor(4);<br />    cprintf(\"
SOFTWARE ENGINEERING PROJECT\"
);<br />    gotoxy(32,44);<br />    textcolor(19);<br />    cprintf(\"
BATCH-1(2006-07)\"
);<br />    gotoxy(23,42);<br />    textcolor(19);<br />    cprintf(\"
ZOO MANAGEMENT SYSTEM ( ZMS-2007 )\"
);<br />    gotoxy(8,45);<br />    textcolor(4);<br />    cprintf(\"
DATE : %s \"
,__DATE__);<br />    gotoxy(55,45);<br />    cprintf(\"
TIME : %s \"
,__TIME__);<br />    for(iInc=0;iInc<=30;iInc++)<br />    {<br />    gotoxy(20,iInc);<br />    textcolor(7);<br />    cprintf(\"
-\"
);<br />    }<br />    for(iInc=0;iInc<=80;iInc++)<br />    {<br />    gotoxy(iInc,30);<br />    textcolor(7);<br />    cprintf(\"
|\"
);<br />    }<br />    gotoxy(30,10);<br />    textcolor(19);<br />    cprintf(\"
1.ADD \"
);<br />    gotoxy(30,12);<br />    cprintf(\"
2.DISPLAY\"
);<br />    gotoxy(30,14);<br />    cprintf(\"
3.MODIFY\"
);<br />    gotoxy(30,16);<br />    cprintf(\"
4.DELETE\"
);<br />    gotoxy(30,18);<br />    cprintf(\"
5.EXIT\"
);<br />    gotoxy(30,20);<br />    textcolor(4);<br />    cprintf(\"
SELECT YOUR OPTION: \"
);<br />    fflush(stdin);<br />    cChoice=getche();<br />    clrscr();<br />    gotoxy(25,8);<br />    textcolor(5);<br />    switch(cChoice)<br />    {<br />    case '1':<br />    //To add a record<br />    w:<br />    printf(\"
\n\n\n\t\tENTER CELL ID( 3 DIGIT NO.): \"
);<br />    scanf(\"
%s\"
,cell_id);<br />    rewind(fp);<br />    //Checking for unique id<br />    while(fread(&e,lRecsize,1,fp)==1)<br />    {<br />    if(strcmp(e.cellid,cell_id)==0)<br />    {<br />    iF=1;<br />    printf(\"
\n\t\tTHE ID ALREADY EXISTS\"
);<br />    goto w;<br />    }}<br />    if(iF==0||fread(&e,lRecsize,1,fp)==0)<br />    {<br />    fseek (fp,0,SEEK_END);<br />    strcpy(e.cellid,cell_id);<br />    a3:<br />    printf(\"
\n\t\tENTER ANIMAL NAME: \"
);<br />    scanf(\"
%s\"
,e.an_name);<br />    if(strlen(e.an_name)>30||strlen(e.an_name)<3)<br />    goto a3;<br />    printf(\"
\n\t\tENTER ZOO KEEPER NAME: \"
);<br />    scanf(\"
%s\"
,e.keeper_nm); <br />    p:<br />    printf(\"
\n\t\tENTER SEX [M/F]: \"
);<br />    scanf(\"
%s\"
,e.an_sex);<br />    if(strlen(e.an_sex)>1)<br />    goto p;<br />    f:<br />    printf(\"
\n\t\tENTER AGE : \"
);<br />    scanf(\"
%d\"
,&e.anim_age);<br />    if(e.anim_age<0||e.anim_age>100)<br />    goto f; <br />    a5:<br />    printf(\"
\n\t\tOFFSPRING [P/A]:\"
);<br />    scanf(\"
%s\"
,&e.offspr);<br />    if(strlen(e.offspr)>1)<br />    goto a5;<br />    printf(\"
\n\t\tENTER NO. OF OFFSPRING: \"
);<br />    scanf(\"
%d\"
,&e.offno);<br />    printf(\"
\n\t\tFOOD SUPPLIED( IN KG): \"
);<br />    scanf(\"
%f\"
,&e.food_s);<br />    printf(\"
\n\t\tFOOD CONSUMED( IN KG): \"
);<br />    scanf(\"
%f\"
,&e.food_c);<br />    a2:<br />    printf(\"
\n\t\tANIMAL DETAILS(IF ANY)\n\t\t(Don't leave space,use '_'): \"
);<br />    scanf(\"
%s\"
,e.anim_history);<br />    if(strlen(e.anim_history)>50)<br />    goto a2;<br />    fwrite(&e,lRecsize,1,fp);<br />    /*Flushes a stream On success returns 0 , On error returns EOF */<br />    fflush(stdin);<br />    }<br />    break;<br />    case '2':<br />    //Searching and displaying all the infor<br />    //     mation by id<br />    textcolor(7);<br />    printf(\"
\n\n\n\t\tENTER CELL ID: \"
);<br />    scanf(\"
%s\"
,cell_id);<br />    rewind(fp);<br />    while(fread(&e,lRecsize,1,fp)!=0)<br />    {<br />    if(strcmp(e.cellid,cell_id)==0)<br />    { iC=1;<br />    clrscr();<br />    //Display according to Main menu<br />    gotoxy(0,20);<br />    //ANIMAL<br />    if(iCh1==1){<br />    printf(\"
\n\n\n\t\tDETAILS OF THE ANIMAL:%s\"
,strupr(e.an_name));<br />    printf(\"
\n_____________________________________________________________________\n\n\"
);<br />    printf(\"
\n\n NAME : %s\t CELL ID : %s\t ZOO KEEPER NAME : %s\n\n SEX: %s\t AGE : %d \n\n OFFSPRING: %s\n\n OFFSPRING NO. : %d\n\n OFFSPRING RATIO : %f\n\n INBREED RATIO : %f\n\n FOOD SUPPLIED : %f\n\n FOOD CONSUMED : %f\n\n ANIMAL DETAILS: %s\"
,strupr(e.an_name),strupr(e.cellid),strupr(e.keeper_nm),strupr(e.an_sex),e.anim_age,strupr(e.offspr),e.offno,(e.offno/13.33*6.2),(e.offno*12.66/17.3574),e.food_s,e.food_c,strupr(e.anim_history));<br />    printf(\"
\n_____________________________________________________________________\n\n\"
);<br />    getch(); }<br />    //BIRD<br />    else if(iCh1==2){<br />    printf(\"
\n\n\n\t\tDETAILS OF BIRD:%s\"
,strupr(e.an_name));<br />    printf(\"
\n_____________________________________________________________________\n\n\"
);<br />    printf(\"
\n\n NAME : %s\t CELL ID : %s\t ZOO KEEPER NAME : %s\n\n AGE: %d\t SEX : %s \t OFFSPRING: %s\n\n OFFSPRING NO. : %d\n\n OFFSPRING RATIO : %f\n\n INBREED RATIO : %f\n\n FOOD SUPPLIED : %f\n\n FOOD CONSUMED : %f\n\n ANIMAL DETAILS: %s\"
,strupr(e.an_name),strupr(e.cellid),strupr(e.keeper_nm),e.anim_age,strupr(e.an_sex),strupr(e.offspr),e.offno,(e.offno/13.33*6.2),(e.offno*12.66/17.3574),e.food_s,e.food_c,strupr(e.anim_history));<br />    printf(\"
\n_____________________________________________________________________\n\n\"
);<br />    getch(); }<br />    }<br />    }<br />    if(iC==0)<br />    {<br />    printf(\"
\n\t\tRECORD DOESN'T EXISTS..\"
);<br />    getch();<br />    }iC=0;<br />    break;<br />    case '3':<br />    //Searching and modifying Records by id<br />    cAns='y';<br />    while(cAns=='y')<br />    {<br />    printf(\"
\n\n\n\t\tENTER CELL ID: \"
);<br />    scanf(\"
%s\"
,cell_id);<br />    rewind(fp);<br />    while(fread(&e,lRecsize,1,fp)==1)<br />    {<br />    if(strcmp(e.cellid,cell_id)==0)<br />    {<br />    b:<br />    printf(\"
\n\n\t\tENTER ANIMAL NAME: %s : \"
,strupr(e.an_name));<br />    scanf(\"
%s\"
,e.an_name);<br />    if(strlen(e.an_name)>20||strlen(e.an_name)<3)<br />    goto b;<br />    b1:<br />    printf(\"
 \n\t\tENTER SEX : %s : \"
,strupr(e.an_sex));<br />    scanf(\"
%s\"
,e.an_sex);<br />    if(strlen(e.an_sex)>1)<br />    goto b1;<br />    r:<br />    printf(\"
 \n\t\tENTER AGE: %d : \"
 ,e.anim_age);<br />    scanf(\"
%d\"
,&e.anim_age);<br />    if(e.anim_age<1||e.anim_age>100)<br />    goto r;<br />    ad:<br />    printf(\"
 \n\t\tOFFSPRING : %s : \"
,strupr(e.offspr));<br />    scanf(\"
%s\"
,e.offspr);<br />    if(strlen(e.offspr)<1)<br />    goto ad;<br />    printf(\"
 \n\t\tENTER NO. OF OFFSPRING: %d :\"
,e.offno);<br />    scanf(\"
%d\"
,&e.offno);<br />    printf(\"
 \n\t\tENTER FOOD SUPPLIED(IN KG): %f :\"
,e.food_s);<br />    scanf(\"
%f\"
,&e.food_s);<br />    printf(\"
\n\t\tFOOD CONSUMED( IN KG): \"
);<br />    scanf(\"
%f\"
,&e.food_c);<br />    b5:<br />    printf(\"
\n\t\tANIMAL DETAILS( IF ANY )\n\t\t(Dont leave space,use'_'instead)': %s : \"
,e.anim_history);<br />    scanf(\"
%s\"
,e.anim_history);<br />    if(strlen(e.anim_history)>50)<br />    goto b5;<br />    fseek(fp,-lRecsize,SEEK_CUR); //Repositions the file pointer of a stream<br />    fwrite(&e,lRecsize,1,fp);<br />    printf(\"
\n\t\tRECORD MODIFIED \"
);<br />    break;<br />    }<br />    }<br />    printf(\"
\n\n\n\t\tDO U WANT TO MODIFY ANY RECORD[y/n]\"
);<br />    /*Flushes a stream On success returns 0 , On error returns EOF */<br />    fflush(stdin);<br />    cAns=getche();<br />    }<br />    break;<br />    case '4':<br />    //Searching and deleting records by id<br />    cAns='y';<br />    while(cAns=='y')<br />    {<br />    printf(\"
\n\n\t\tENTER CELL ID TO DELETE RECORD : \"
);<br />    scanf(\"
%s\"
,cell_id);<br />    ft=fopen(\"
temp.dat\"
,\"
wb\"
);<br />    rewind(fp); //Repositions file pointer to stream's beginning<br />    while(fread(&e,lRecsize,1,fp)!=0)<br />    {<br />    if(strcmp(e.cellid,cell_id)!=0) {<br />    fwrite(&e,lRecsize,1,ft);<br />    }<br />    else {<br />    iF1=1;<br />    printf(\"
\n\n\t\t RECORD DELETED SUCCESSFULLY\"
);<br />    }<br />    }<br />    if(iF1!=1){iF1=0;<br />    printf(\"
\n\n\t\t NO SUCH RECORD FOUND\"
);}<br />    fclose(fp);<br />    fclose(ft);<br />    remove(\"
zm.dat\"
);<br />    rename(\"
temp.dat\"
,\"
zm.dat\"
);<br />    fp=fopen(\"
zm.dat\"
,\"
rb+\"
);<br />    printf(\"
\n\n\t\tDO U WANT TO DELETE ANOTHER RECORD[y/n]\"
);<br />    fflush(stdin);<br />    cAns=getche();<br />    }<br />    break;<br />    case '5':<br />    fclose(fp);<br />    goto e;<br />    }<br />    }<br />    }<br />    }<br />
Zoo management  adri jovin
Zoo management  adri jovin
Zoo management  adri jovin
Zoo management  adri jovin
Zoo management  adri jovin
Zoo management  adri jovin
Zoo management  adri jovin

Zoo management adri jovin

  • 1.
    #include<stdio.h><br /> #include<conio.h><br /> #include<dos.h><br /> #include<string.h><br /> void main()<br /> {<br /> int iCh1,iInc;<br /> e:<br /> clrscr();<br /> /* To Display Main menu */<br /> gotoxy(26,40);<br /> textcolor(9);<br /> cprintf(\" SOFTWARE ENGINEERING PROJECT\" );<br /> gotoxy(32,44);<br /> textcolor(19);<br /> cprintf(\" BATCH-1(2006-07)\" );<br /> gotoxy(23,42);<br /> cprintf(\" ZOO MANAGEMENT SYSTEM ( ZMS-2007)\" );<br /> gotoxy(8,45);<br /> textcolor(9);<br /> /* To Dispaly date and time */<br /> cprintf(\" DATE : %s \" ,__DATE__);<br /> gotoxy(55,45);<br /> cprintf(\" TIME : %s \" ,__TIME__);<br /> for(iInc=0;iInc<=30;iInc++)<br /> {<br /> gotoxy(20,iInc);<br /> textcolor(7);<br /> cprintf(\" -\" );<br /> }<br /> for(iInc=0;iInc<80;iInc++)<br /> {<br /> gotoxy(iInc,30);<br /> textcolor(7);<br /> cprintf(\" |\" );<br /> }<br /> gotoxy(30,8);<br /> textcolor(9);<br /> /* Main menu */<br /> cprintf(\" ZOO MANAGEMENT SYSTEM (ZMS-2007)\" );<br /> gotoxy(30,10);<br /> textcolor(19);<br /> cprintf(\" 1.ANIMAL\" );<br /> gotoxy(30,12);<br /> cprintf(\" 2.BIRD\" );<br /> gotoxy(30,14);<br /> cprintf(\" 3.EXIT\" );<br /> gotoxy(30,18);<br /> textcolor(9);<br /> cprintf(\" ENTER YOUR CHOICE:\" );<br /> scanf(\" %d\" ,&iCh1);<br /> if<br /> (iCh1==3)<br /> {<br /> /* To exit from the system */<br /> gotoxy(30,28);<br /> textcolor(4);<br /> cprintf(\" SYSTEM SHUTTING DOWN\" );<br /> sleep(3);<br /> gotoxy(26,40);<br /> printf(\" SOFTWARE ENGINEERING PROJECT\" );<br /> gotoxy(8,42);<br /> printf(\" ZOO MANAGEMENT SYSTEM ( ZMS-2007)\" );<br /> gotoxy(8,45);<br /> printf(\" DATE : %s \" ,__DATE__);<br /> gotoxy(55,45);<br /> printf(\" TIME : %s \" ,__TIME__);<br /> exit(0);<br /> }<br /> else{<br /> /* Declarations of Variables */<br /> FILE *fp,*ft;<br /> char cAns,cChoice;<br /> struct zoo<br /> {<br /> char offspr[2],anim_history[50],an_name[30],keeper_nm[20],cellid[4],an_sex[2];<br /> int anim_age,offno;<br /> float wt,offrat,inbreed,food_s,food_c;<br /> };<br /> struct zoo e;<br /> char cell_id[4];<br /> int iF=0,iC=0,iF1=0;<br /> long int lRecsize;<br /> fp=fopen(\" zm.dat\" ,\" rb+\" );<br /> if(fp==NULL)<br /> {<br /> fp=fopen(\" \zm.dat\" ,\" wb+\" );<br /> if(fp==NULL)<br /> {<br /> puts(\" \n\t\tCannot Open file\" );<br /> exit();<br /> }<br /> }<br /> lRecsize=sizeof(e);<br /> while(1)<br /> {<br /> clrscr();<br /> textcolor(4);<br /> if(iCh1==1) {<br /> gotoxy(30,8);<br /> textcolor(4);<br /> cprintf(\" ANIMAL MENU\" ); }<br /> else if(iCh1==2) {<br /> gotoxy(30,8);<br /> textcolor(4);<br /> cprintf(\" BIRD MENU\" ); }<br /> gotoxy(26,40);<br /> textcolor(4);<br /> cprintf(\" SOFTWARE ENGINEERING PROJECT\" );<br /> gotoxy(32,44);<br /> textcolor(19);<br /> cprintf(\" BATCH-1(2006-07)\" );<br /> gotoxy(23,42);<br /> textcolor(19);<br /> cprintf(\" ZOO MANAGEMENT SYSTEM ( ZMS-2007 )\" );<br /> gotoxy(8,45);<br /> textcolor(4);<br /> cprintf(\" DATE : %s \" ,__DATE__);<br /> gotoxy(55,45);<br /> cprintf(\" TIME : %s \" ,__TIME__);<br /> for(iInc=0;iInc<=30;iInc++)<br /> {<br /> gotoxy(20,iInc);<br /> textcolor(7);<br /> cprintf(\" -\" );<br /> }<br /> for(iInc=0;iInc<=80;iInc++)<br /> {<br /> gotoxy(iInc,30);<br /> textcolor(7);<br /> cprintf(\" |\" );<br /> }<br /> gotoxy(30,10);<br /> textcolor(19);<br /> cprintf(\" 1.ADD \" );<br /> gotoxy(30,12);<br /> cprintf(\" 2.DISPLAY\" );<br /> gotoxy(30,14);<br /> cprintf(\" 3.MODIFY\" );<br /> gotoxy(30,16);<br /> cprintf(\" 4.DELETE\" );<br /> gotoxy(30,18);<br /> cprintf(\" 5.EXIT\" );<br /> gotoxy(30,20);<br /> textcolor(4);<br /> cprintf(\" SELECT YOUR OPTION: \" );<br /> fflush(stdin);<br /> cChoice=getche();<br /> clrscr();<br /> gotoxy(25,8);<br /> textcolor(5);<br /> switch(cChoice)<br /> {<br /> case '1':<br /> //To add a record<br /> w:<br /> printf(\" \n\n\n\t\tENTER CELL ID( 3 DIGIT NO.): \" );<br /> scanf(\" %s\" ,cell_id);<br /> rewind(fp);<br /> //Checking for unique id<br /> while(fread(&e,lRecsize,1,fp)==1)<br /> {<br /> if(strcmp(e.cellid,cell_id)==0)<br /> {<br /> iF=1;<br /> printf(\" \n\t\tTHE ID ALREADY EXISTS\" );<br /> goto w;<br /> }}<br /> if(iF==0||fread(&e,lRecsize,1,fp)==0)<br /> {<br /> fseek (fp,0,SEEK_END);<br /> strcpy(e.cellid,cell_id);<br /> a3:<br /> printf(\" \n\t\tENTER ANIMAL NAME: \" );<br /> scanf(\" %s\" ,e.an_name);<br /> if(strlen(e.an_name)>30||strlen(e.an_name)<3)<br /> goto a3;<br /> printf(\" \n\t\tENTER ZOO KEEPER NAME: \" );<br /> scanf(\" %s\" ,e.keeper_nm); <br /> p:<br /> printf(\" \n\t\tENTER SEX [M/F]: \" );<br /> scanf(\" %s\" ,e.an_sex);<br /> if(strlen(e.an_sex)>1)<br /> goto p;<br /> f:<br /> printf(\" \n\t\tENTER AGE : \" );<br /> scanf(\" %d\" ,&e.anim_age);<br /> if(e.anim_age<0||e.anim_age>100)<br /> goto f; <br /> a5:<br /> printf(\" \n\t\tOFFSPRING [P/A]:\" );<br /> scanf(\" %s\" ,&e.offspr);<br /> if(strlen(e.offspr)>1)<br /> goto a5;<br /> printf(\" \n\t\tENTER NO. OF OFFSPRING: \" );<br /> scanf(\" %d\" ,&e.offno);<br /> printf(\" \n\t\tFOOD SUPPLIED( IN KG): \" );<br /> scanf(\" %f\" ,&e.food_s);<br /> printf(\" \n\t\tFOOD CONSUMED( IN KG): \" );<br /> scanf(\" %f\" ,&e.food_c);<br /> a2:<br /> printf(\" \n\t\tANIMAL DETAILS(IF ANY)\n\t\t(Don't leave space,use '_'): \" );<br /> scanf(\" %s\" ,e.anim_history);<br /> if(strlen(e.anim_history)>50)<br /> goto a2;<br /> fwrite(&e,lRecsize,1,fp);<br /> /*Flushes a stream On success returns 0 , On error returns EOF */<br /> fflush(stdin);<br /> }<br /> break;<br /> case '2':<br /> //Searching and displaying all the infor<br /> // mation by id<br /> textcolor(7);<br /> printf(\" \n\n\n\t\tENTER CELL ID: \" );<br /> scanf(\" %s\" ,cell_id);<br /> rewind(fp);<br /> while(fread(&e,lRecsize,1,fp)!=0)<br /> {<br /> if(strcmp(e.cellid,cell_id)==0)<br /> { iC=1;<br /> clrscr();<br /> //Display according to Main menu<br /> gotoxy(0,20);<br /> //ANIMAL<br /> if(iCh1==1){<br /> printf(\" \n\n\n\t\tDETAILS OF THE ANIMAL:%s\" ,strupr(e.an_name));<br /> printf(\" \n_____________________________________________________________________\n\n\" );<br /> printf(\" \n\n NAME : %s\t CELL ID : %s\t ZOO KEEPER NAME : %s\n\n SEX: %s\t AGE : %d \n\n OFFSPRING: %s\n\n OFFSPRING NO. : %d\n\n OFFSPRING RATIO : %f\n\n INBREED RATIO : %f\n\n FOOD SUPPLIED : %f\n\n FOOD CONSUMED : %f\n\n ANIMAL DETAILS: %s\" ,strupr(e.an_name),strupr(e.cellid),strupr(e.keeper_nm),strupr(e.an_sex),e.anim_age,strupr(e.offspr),e.offno,(e.offno/13.33*6.2),(e.offno*12.66/17.3574),e.food_s,e.food_c,strupr(e.anim_history));<br /> printf(\" \n_____________________________________________________________________\n\n\" );<br /> getch(); }<br /> //BIRD<br /> else if(iCh1==2){<br /> printf(\" \n\n\n\t\tDETAILS OF BIRD:%s\" ,strupr(e.an_name));<br /> printf(\" \n_____________________________________________________________________\n\n\" );<br /> printf(\" \n\n NAME : %s\t CELL ID : %s\t ZOO KEEPER NAME : %s\n\n AGE: %d\t SEX : %s \t OFFSPRING: %s\n\n OFFSPRING NO. : %d\n\n OFFSPRING RATIO : %f\n\n INBREED RATIO : %f\n\n FOOD SUPPLIED : %f\n\n FOOD CONSUMED : %f\n\n ANIMAL DETAILS: %s\" ,strupr(e.an_name),strupr(e.cellid),strupr(e.keeper_nm),e.anim_age,strupr(e.an_sex),strupr(e.offspr),e.offno,(e.offno/13.33*6.2),(e.offno*12.66/17.3574),e.food_s,e.food_c,strupr(e.anim_history));<br /> printf(\" \n_____________________________________________________________________\n\n\" );<br /> getch(); }<br /> }<br /> }<br /> if(iC==0)<br /> {<br /> printf(\" \n\t\tRECORD DOESN'T EXISTS..\" );<br /> getch();<br /> }iC=0;<br /> break;<br /> case '3':<br /> //Searching and modifying Records by id<br /> cAns='y';<br /> while(cAns=='y')<br /> {<br /> printf(\" \n\n\n\t\tENTER CELL ID: \" );<br /> scanf(\" %s\" ,cell_id);<br /> rewind(fp);<br /> while(fread(&e,lRecsize,1,fp)==1)<br /> {<br /> if(strcmp(e.cellid,cell_id)==0)<br /> {<br /> b:<br /> printf(\" \n\n\t\tENTER ANIMAL NAME: %s : \" ,strupr(e.an_name));<br /> scanf(\" %s\" ,e.an_name);<br /> if(strlen(e.an_name)>20||strlen(e.an_name)<3)<br /> goto b;<br /> b1:<br /> printf(\" \n\t\tENTER SEX : %s : \" ,strupr(e.an_sex));<br /> scanf(\" %s\" ,e.an_sex);<br /> if(strlen(e.an_sex)>1)<br /> goto b1;<br /> r:<br /> printf(\" \n\t\tENTER AGE: %d : \" ,e.anim_age);<br /> scanf(\" %d\" ,&e.anim_age);<br /> if(e.anim_age<1||e.anim_age>100)<br /> goto r;<br /> ad:<br /> printf(\" \n\t\tOFFSPRING : %s : \" ,strupr(e.offspr));<br /> scanf(\" %s\" ,e.offspr);<br /> if(strlen(e.offspr)<1)<br /> goto ad;<br /> printf(\" \n\t\tENTER NO. OF OFFSPRING: %d :\" ,e.offno);<br /> scanf(\" %d\" ,&e.offno);<br /> printf(\" \n\t\tENTER FOOD SUPPLIED(IN KG): %f :\" ,e.food_s);<br /> scanf(\" %f\" ,&e.food_s);<br /> printf(\" \n\t\tFOOD CONSUMED( IN KG): \" );<br /> scanf(\" %f\" ,&e.food_c);<br /> b5:<br /> printf(\" \n\t\tANIMAL DETAILS( IF ANY )\n\t\t(Dont leave space,use'_'instead)': %s : \" ,e.anim_history);<br /> scanf(\" %s\" ,e.anim_history);<br /> if(strlen(e.anim_history)>50)<br /> goto b5;<br /> fseek(fp,-lRecsize,SEEK_CUR); //Repositions the file pointer of a stream<br /> fwrite(&e,lRecsize,1,fp);<br /> printf(\" \n\t\tRECORD MODIFIED \" );<br /> break;<br /> }<br /> }<br /> printf(\" \n\n\n\t\tDO U WANT TO MODIFY ANY RECORD[y/n]\" );<br /> /*Flushes a stream On success returns 0 , On error returns EOF */<br /> fflush(stdin);<br /> cAns=getche();<br /> }<br /> break;<br /> case '4':<br /> //Searching and deleting records by id<br /> cAns='y';<br /> while(cAns=='y')<br /> {<br /> printf(\" \n\n\t\tENTER CELL ID TO DELETE RECORD : \" );<br /> scanf(\" %s\" ,cell_id);<br /> ft=fopen(\" temp.dat\" ,\" wb\" );<br /> rewind(fp); //Repositions file pointer to stream's beginning<br /> while(fread(&e,lRecsize,1,fp)!=0)<br /> {<br /> if(strcmp(e.cellid,cell_id)!=0) {<br /> fwrite(&e,lRecsize,1,ft);<br /> }<br /> else {<br /> iF1=1;<br /> printf(\" \n\n\t\t RECORD DELETED SUCCESSFULLY\" );<br /> }<br /> }<br /> if(iF1!=1){iF1=0;<br /> printf(\" \n\n\t\t NO SUCH RECORD FOUND\" );}<br /> fclose(fp);<br /> fclose(ft);<br /> remove(\" zm.dat\" );<br /> rename(\" temp.dat\" ,\" zm.dat\" );<br /> fp=fopen(\" zm.dat\" ,\" rb+\" );<br /> printf(\" \n\n\t\tDO U WANT TO DELETE ANOTHER RECORD[y/n]\" );<br /> fflush(stdin);<br /> cAns=getche();<br /> }<br /> break;<br /> case '5':<br /> fclose(fp);<br /> goto e;<br /> }<br /> }<br /> }<br /> }<br />