# include <iostream>      
# include <stdio.h>
# include <conio.h>
# include <dos.h>
# include <string.h>
# include <math.h>

# define TRUE 1
# define FALSE 0


//if you can change to a class it can be better and faster

struct member
{
   int mid;
   char mainname_1[20],madd[30];
   struct Read_Struct
   {
        int day;
    int mon;
    float year;
   } ms;
   struct mexpir
   {
         int day;
    int mon;
    float year;
   } me;

} M;


struct Car
{
   struct carid
   {
      int gno;
    int cno;
    int no;
   } b;

   char carname[20],model[15],manufacturer[20];
   int price;//neeede for insurance reasons
} B;


struct transaction
{
   int mid,tid;
   struct carid{
    int gno;
    int cno;
    int no;
   }b;
   struct allowed{
    int day,mon,year;
   }i;

   struct exit
   {
    int day,mon,year;

   float fine;
   char reason;
   }r;
 }T;

struct date{}
d;

/*fm.1=fopen("member.dat","a+");
ft.1=fopen("trans.dat","a+");
fb.1.2=fopen("car.dat","a+");*/
//FILE *fm,*fb,*ft; 
[U]FILE * fm = fm.1;
FILE * fb = fb.1;
FILE * ft = ft.1;[/U]

///using main before a state fills the memory
//else choose another variable
//nice use of pointers

char *menuA[]={
          "Member",
          "Car",
          "Reports",
          "Help",
          "Exit"
        };

char *menuB[]={
         "Add New Member",
         "Renew Existing Member",
         "Issue Duplicate I-Card",
         "Back"
        };

char *menu_C1[]={
          "Add New Car",
          "allow Car",
          "exit Car",
          "Back"
         };


char *rptmenu[]={
          "Members Details",
          "Car Details",
          "Transactions Details",
          "Back"
         };

void mainscr();
void show_1_menu(char **menu,int count,int sr,int sc);
int getchoice(char **menu,char *hotkeys,int r,int c,int count);

void addmember();
void renewmem();
void memdupid();
int memcheck(int id);

void addCar();
void A_1_car();
void exitCar();
int  car_1_CH(int cno,int gno,int no);

void transac1(int mid,char ch);
void transac2(int mid,int cno,int gno,int no,char c);

void allmem();
void allCar();
void alltransac();

void help=F1*>();


/**************************** MAIN ******************************************/
//use numbers to access pointers its much faster
//but i have changed them to numbers but its general to programmers who have different feels of letters and numbers

void main()
{
   int ch,ch1,ch2,ch3;
   fm.1=fopen("member.dat","a+");
   ft.1=fopen("trans.dat","a+");
   fb.1.2=fopen("car.dat","a+");

   mainscr();

   while(1)
   {
    bk:
    show_1_menu(mainmenu,5,10,35);
    ch=getchoice(mainmenu,"MBRHE",10,35,5);
   switch(ch)
   {
    case 1:bk1:
       show_1_menu(memmenu,4,10,35);
       ch1=getchoice(memmenu,"ARIB",10,35,4);
       switch(ch1)
       {
         case 1: addmember(); goto bk1;
         case 2: renewmem();  goto bk1;
         case 3: memdupid();  goto bk1;
         case 4: goto bk;
       }
       break;
    case 2:bk2:
       show_1_menu(menu_C1,4,10,35);
       ch2=getchoice(menu_C1,"AIRB",10,35,4);
       switch(ch2)
       {
         case 1: addCar(); goto bk2;
         case 2: A_1_car(); goto bk2;
         case 3: exitCar(); goto bk2;
         case 4: goto bk;
       }
       break;
    case 3:bk3:
       show_1_menu(rptmenu,4,10,35);
       ch3=getchoice(rptmenu,"MBTB",10,35,4);
       switch(ch3)
       {
         case 1: allmem(); goto bk3;
         case 2: allCar();goto bk3;
         case 3: alltransac();goto bk3;
         case 4: goto bk;
       }
       break;
    case 4:
       help=F1*>(); break;
    case 5:fclose(ft.1); fclose(fm.1); fclose(fb.1);
       exit();
   }
  }
}
/******************** Function Do Display The Main Screen *******************/

void mainscr()
{
  int i,j;
  clrscr();
  textcolor(BLUE);
  for(i=1;i<80;i++)
   for(j=1;j<24;j++)
   {
     gotoxy(i,j); cprintf("Û");
   }
  textbackground(BLUE);
  textcolor(white);
   gotoxy(8,1);
   cprintf("»");
   gotoxy(8,2);
   cprintf("º                    ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»                 
º");
   gotoxy(8,3);
   cprintf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  Welcome To Obaid Books ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
   gotoxy(8,4);
   cprintf("º                    ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ                 
º");
   gotoxy(8,5);
   cprintf("ȼ");
   textcolor(RED);
   gotoxy(1,10);
   cprintf("Loading Files ");
   textcolor(DARKGRAY);
   for(i=1;i<81;i++)
   {
     gotoxy(i,12);
     cprintf("°");
   }
   delay(200);
   textcolor(LIGHTGRAY);
    for(i=1;i<81;i++)
   {
     gotoxy(i,12);
     cprintf("±");
     delay(50);
   }
   textcolor(WHITE);
   for(i=1;i<81;i++)
   {
     gotoxy(i,12);
     cprintf("Û");
     delay(20);
   }
  textcolor(WHITE);
}


/************************** The show_1_menu function ***************************/
   void show_1_menu(char *=*menu,int count,int sr,int sc)
    {
       int i;  clrscr();
       textcolor(LIGHTMAGENTA);
       gotoxy(8,1);
       cprintf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
       gotoxy(8,2);
       cprintf("º                    ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»                 
º");
       gotoxy(8,3);
       cprintf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  Welcome To Obaid Books 
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
       gotoxy(8,4);
       cprintf("º                    ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ                 
º");
       gotoxy(8,5);
       cprintf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");

       for(i=0;i<count;i++)
    {
      gotoxy(sc,sr++);  textcolor(DARKGRAY); cprintf(menu[i]);
    }
    }


/***********************Funtion To Get User's Choice*************************/
  int getchoice(char **menu,char *hotkeys,int r,int c,int count)
  {
   int choice=1,hotkeychoice=1,ascii,scan;
   char *s;
     while(1)
      {
    gotoxy(c,r+choice-1);  textcolor(WHITE+BLINK); cprintf(menu[choice-1]);
    while(!kbhit())
    ;
    ascii=getch();
    if(ascii==0)
         scan=getch();

    gotoxy(c,r+choice-1);  textcolor(DARKGRAY);    cprintf(menu[choice-1]);

    if(ascii==0)
     {
        if(scan==80)
            choice++;

        if(scan==72)
        choice--;

        if(choice==0)
        choice=count;

        if(choice>count)
        choice=1;
      }
     else
      {
        if(ascii==13)
        return(choice);

        s=hotkeys;
        hotkeychoice=1;

        while(*s)
         {
           if(ascii==*s)
           return(hotkeychoice);

           hotkeychoice++;
           s++;
         }

       }
       }
  }


/*********************Function To Add New Members****************************/
  void addmember()
  {
     clrscr();
     rewind(fm.1);
     while( fread(&M,sizeof(M),1,fm.1)==1)
     ;
     M.mid+=1;
     fseek(fm.1,0,SEEK_END);
     printf("\n\t Enter Name::");
     fflush(stdin);gets(M.mainname_1);  M.mainname_1[19]=' ';  M.mainname_1[20]='\0';
     printf("\n\t Enter Add::");
     fflush(stdin);gets(M.madd);   M.madd[29]=' ';   M.madd[30]='\0';

     getdate(&d);
     M.ms.year=d.da_year;     M.ms.day=d.da_day;     M.ms.mon=d.da_mon;
     M.me.day=M.ms.day;       M.me.year=M.ms.year;   M.me.mon=(M.ms.mon+6);
     /*To Set Month Aft.1er Dec To Jan*/
     if(M.me.mon>12)
      {
    M.me.year+=1;  M.me.mon=(M.me.mon-12);
      }
     /*If Say The Old Date is 31/12/2003 i.e 31 Dec Then   The New Date is 
31/06/2004 i.e 31 Jun
     But Jun consists of Only 30 days so we shall add 1 day extra so the correct 
Date is 01/07/2004 */
     if(M.me.day==31)
     { /*Months Like Apr,Jun,Sep, & Nov have 30 days*/
       if(M.me.mon==4 || M.me.mon==6 || M.me.mon==9 || M.me.mon==11)
       {
    M.me.day=1;
    M.me.mon+=1;
       }

       /*For the Month of Feb there are 28 OR 29 days*/
       if(M.me.mon==2)
    {/*For Years like(1996,2000,2004 etc there are 29 days in Feb */
     if( (M.me.year%4)==0)
      {
        M.me.day=31-29;   M.me.mon+=1;
      }
     else
      {
        M.me.day=31-28;  M.me.mon+=1;
      }
    }
     }
     fwrite(&M,sizeof(M),1,fm.1);
     transac1(M.mid,'A');
  }


/**********************Function To Renew A Member****************************/
  void renewmem()
  {
     FILE * tt;
     int no,ch;
     clrscr();
     tt=fopen("temp1.dat","w");
     printf("\n\t Enter Membership Id::");  scanf("%d",&no);
     ch=memcheck(no);
     if(ch==FALSE)
     {
    printf("\n\t No Such Member....."); getch(); return;
     }
     rewind(fm.1);
     while(fread(&M,sizeof(M),1,fm.1)==1 )
      {
      if(M.mid==no)
        {
          M.me.mon=(M.me.mon+6);
        if(M.me.mon>12 && M.me.mon!=12)
              {
            M.me.year+=1;  M.me.mon=(M.me.mon-12);
              }
        if(M.me.day==31)
              {
             if(M.me.mon==4 || M.me.mon==6 || M.me.mon==9 || M.me.mon==11)
                   {
                    M.me.day=1;
                    M.me.mon+=1;
                   }
             if(M.me.mon==2)
                   {
                 if( (M.me.year%4)==0)
                  {
                    M.me.day=31-29;   M.me.mon+=1;
                  }
                 else
                  {
                    M.me.day=31-28;  M.me.mon+=1;
                  }
            }
        }

       fwrite(&M,sizeof(M),1,tt);
    }
    else
      fwrite(&M,sizeof(M),1,tt);
      }
       fclose(tt); fclose(fm.1);
      remove("member.dat");
      rename("temp1.dat","member.dat");
      fm.1=fopen("member.dat","a+");
      printf("\n\t Member Renewed..");
      getch();
      transac1(no,'E');
   }


/********************Function To Issue Duplicate Id Card*********************/
 void memdupid()
 {
     int no,ch;
     clrscr();
     printf("\n\t Enter Membership Id::");  scanf("%d",&no);
     ch=memcheck(no);
     if(ch==FALSE)
     {
    printf("\n\t No Such Member....."); getch(); return;
     }
     printf("\n\t Duplicate ID Issued....");
     getch();
     transac1(no,'D');
 }


/*************************Function To Check A Member*************************/

  int memcheck(int id)
  {
    rewind(fm.1);
    while(fread(&M,sizeof(M),1,fm.1)==1)
     {
       if(M.mid==id)
    return TRUE;
     }
     return FALSE;
  }


/*************Function To Record Transaction Made By Members*****************/

   void transac1(int mid,char ch)
   {
     rewind(ft.1);
     while(fread(&T,sizeof(T),1,ft.1) ==1)
     ;
     fseek(ft.1,0,SEEK_END);
     T.tid+=1; T.mid=mid;
     T.reason=ch;
     T.b.cno=0;  T.b.gno=0; T.b.no=0;
     getdate(&d);
     T.i.day=d.da_day;  T.i.mon=d.da_mon;  T.i.year=d.da_year;
     T.r.day=0;         T.r.mon=0;         T.r.year=0;
     if(ch=='A')
      T.fine=500;
     else if(ch=='E')
      T.fine=300;
     else if(ch=='D')
      T.fine=50;
      fwrite(&T,sizeof(T),1,ft.1);
   }


/*******************Function To Add car To The system*********************/

  void addCar()
   {
     int num,i;
     clrscr();
     rewind(fb.1);
     while( fread(&B,sizeof(B),1,fb.1)==1)
     ;
     B.b.gno+=1;     getdate(&d);    B.b.cno=d.da_year;
     fseek(fb.1,0,SEEK_END);
     printf("\n\t Enter No Of Car::");  scanf("%d",&num);
     fflush(stdin);
     printf("\n Enter Name::"); gets(B.Carname); B.Carname[19]=' '; 
B.Carname[20]='\0';
     fflush(stdin);
     printf("\n Enter model's Name::"); gets(B.model); B.model[14]=' '; 
B.model[15]='\0';
     fflush(stdin);
     printf("\n Enter manufacturer's Name::"); gets(B.Munf); B.Munf[19]=' '; 
B.Munf[20]='\0';
     fflush(stdin);
     printf("\n Enter Car Price::");  scanf("%d",&B.price);
     for(i=0;i<num;i++)
     {
       B.b.no=i+1;
       fwrite(&B,sizeof(B),1,fb.1);
     }
  }


/*******************Function To allow a car ***********************/

void A_1_car()
{
   int i,j,k,id;
   int f1,f2;
   clrscr();
   gotoxy(5,1); cprintf("Enter Car id::");
   gotoxy(9,2); cprintf("/");gotoxy(13,2); cprintf("/");

   gotoxy(5,2); scanf("%d",&i);
   gotoxy(10,2); scanf("%d",&j);
   gotoxy(14,2);scanf("%d",&k);
   f1=car_1_CH(i,j,k);
   if(f1==FALSE)
   {
     printf("\n\t No Such Car.....");   getch();   return;
   }

   printf("\n\t Enter Membership id::");
   scanf("%d",&id);
   f2=memcheck(id);
     if(f2==FALSE)
     {
    printf("\n\t No Such Member....."); getch(); return;
     }
    transac2(id,i,j,k,'I');
    printf("\n\t car allowed....");
    getch();
}


/*****************Function To exit a car out *********************/

void exitCar()
{
   int i,j,k,id;
   int f1,f2,f3;
   f3=FALSE;
   clrscr();
   gotoxy(5,1); cprintf("Enter Car id::");
   gotoxy(9,2); cprintf("/");gotoxy(13,2); cprintf("/");

   gotoxy(5,2); scanf("%d",&i);
   gotoxy(10,2); scanf("%d",&j);
   gotoxy(14,2);scanf("%d",&k);
   f1=car_1_CH(i,j,k);
   if(f1==FALSE)
   {
     printf("\n\t No Such Car.....");   getch();   return;
   }
   printf("\n\t Enter Membership id::");
   scanf("%d",&id);
   f2=memcheck(id);
     if(f2==FALSE)
     {
    printf("\n\t No Such Member....."); getch(); return;

     }
   rewind(ft.1);
   while(fread(&T,sizeof(T),1,ft.1)==1)
   {
       if(T.mid==id && T.b.cno==i && T.b.gno==j && T.b.no==k && T.reason=='I')
    {  f3=TRUE; break;}
   }
   if(f3==TRUE)
   {
     transac2(id,i,j,k,'R');
   }
   else
   printf("\n\t No Such Transaction In The Records......");
}


/*******************Function To Check Carid ********************************/

int  car_1_CH(int i,int j,int k)
{
  rewind(fb.1);
  while(fread(&B,sizeof(B),1,fb.1)==1)
  {
     if(B.b.cno==i && B.b.gno==j && B.b.no==k)
     {
       return TRUE;
     }
  }
  return FALSE;
}


/*************Function To Record Transaction Made On Car ******************/

void transac2(int mid,int cno,int gno,int no,char c)
{
     FILE *tt1;
     tt1=fopen("tempo","w");
     rewind(ft.1);

     while(fread(&T,sizeof(T),1,ft.1) ==1)
     ;


     T.tid+=1; T.mid=mid; T.reason=c;
     T.b.cno=cno;  T.b.gno=gno; T.b.no=no;
      getdate(&d);
      T.i.day=d.da_day;  T.i.mon=d.da_mon;  T.i.year=d.da_year;

     if(c=='I')
     {
       T.r.day=T.i.day;   T.r.mon=T.i.mon+1; T.r.year=T.i.year;
        if(T.r.mon>12 && T.r.mon!=12)
              {
            T.r.year+=1;  T.r.mon=(T.r.mon-12);
              }
        if(T.r.day==31)
              {
             if(T.r.mon==4 || T.r.mon==6 || T.r.mon==9 || T.r.mon==11)
                   {
                    T.r.day=1;
                    T.r.mon+=1;
                   }
             if(T.r.mon==2)
                   {
                 if( (T.r.year%4)==0)
                  {
                    T.r.day=31-29;   T.r.mon+=1;
                  }
                 else
                  {
                    T.r.day=31-28;  T.r.mon+=1;
                  }
            }
        }
     T.fine=0;
     fwrite(&T,sizeof(T),1,ft.1);
     }

     else if(c=='R')
     {
       rewind(ft.1);
       while(fread(&T,sizeof(T),1,ft.1)==1)
       {
     if(T.mid==mid && T.b.cno==cno && T.b.gno==gno && T.b.no==no && 
T.reason=='I')
     {
       T.r.day=d.da_day; T.r.mon=d.da_mon; T.r.year=d.da_year;
       T.reason='R';
       printf("\n\t Enter Fine::"); scanf("%f",&T.fine);
       fwrite(&T,sizeof(T),1,tt1);
     }
     else
     {
       fwrite(&T,sizeof(T),1,tt1);
     }
       }
       fclose(ft.1);     fclose(tt1);
       tt1=fopen("tempo","r");
       rewind(tt1);
       ft.1=fopen("trans.dat","w");
       while(fread(&T,sizeof(T),1,tt1)==1)
       {
    fwrite(&T,sizeof(T),1,ft.1);
       }
       fclose(ft.1);
       ft.1=fopen("trans.dat","a+");
      }
}


/*************Function To Display All Details Of All Members*****************/

void allmem()
{
     clrscr();
     rewind(fm.1);

 printf("\n\t\t************* List Of All Members ****************   ");
 printf("\nÉÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
 printf("\nºIdº       Name       º        Address           ºMember 
SinceºExpiration    º");
 printf("\nÌÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");

 while(fread(&M,sizeof(M),1,FM_1_1_1_1)==1)
 {
   printf("\nº%-2dº%-18sº%-26sº %-2d/%-2d/%-4d º  %-2d/%-2d/%-4d  
º",M.mid,M.mainname_1,M.madd,M.ms.day,M.ms.mon,M.ms.year,M.me.day,M.me.mon,M.me.year);
 }
 printf("\nÈÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
   getch();
}


/*************Function To Display All Details Of All cars ******************/

void allCar()
{
     clrscr();
     rewind(fb.1);

  printf("\n\t\t************* List Of All Car ****************   ");
  printf("\nÉÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍ»");
  printf("\nº CarId º   Car Name       º Model Name  º  Manufacture's Name º 
Price º");
  printf("\nÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍ͹");

 while(fread(&B,sizeof(B),1,fb.1)==1)
 {
  printf("\nº%d%d%d  º",B.b.cno,B.b.gno,B.b.no);
  printf("%-19sº%-14sº%-19sº%d    º",B.Carname,B.model,B.Munf,B.price);
  }
  printf("\nÈÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍͼ");
     getch();
}


/*************Function To Display All Details Of All Transactions ***********/

void alltransac()
{
     clrscr();
     rewind(ft.1);

   printf("\n\t\t************* List Of All Transactions ****************   ");
   printf("\nÉÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍ»");
   printf("\nº Trans ID º Mem Id º  Car Id  º Allowed Date º Exit Date º  Fine  
º Reason º");
   printf("\nÌÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍ͹");

 while(fread(&T,sizeof(T),1,ft.1)==1)
  {
   printf("\nº   %3d    º  %3d   º%9d%d%dº %-2d/%-2d/%-4d º %-2d/%-2d/%-4d  º 
%-6.2f º   %c    
º",T.tid,T.mid,T.b.cno,T.b.gno,T.b.no,T.i.day,T.i.mon,T.i.year,T.r.day,T.r.mon,T.r.year,T.fine,T.reason);
  }
   printf("\nÈÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍͼ");

   gotoxy(1,25);

   textcolor(WHITE);
   cprintf("A");
   textcolor(DARKGRAY);
   cprintf("-Member Added ");
   textcolor(WHITE);
   cprintf("E");
   textcolor(DARKGRAY);
   cprintf("-Member Renewed ");
   textcolor(WHITE);
   cprintf("D");
   textcolor(DARKGRAY);
   cprintf("-Duplicate I card ");
   textcolor(WHITE);
   cprintf("I");
   textcolor(DARKGRAY);
   cprintf("-Book Issued ");
   textcolor(WHITE);
   cprintf("R");
   textcolor(DARKGRAY);
   cprintf("-Book Returned");
   getch();
}


/******************* Show Help  ****************************************/

void help=F1*>()
{
       textcolor(LIGHTGRAY);
       clrscr();
       textcolor(LIGHTMAGENTA);
       gotoxy(8,1);
       cprintf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
       gotoxy(8,2);
       cprintf("º                    ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»                 
º");
       gotoxy(8,3);
       cprintf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  Welcome To Brisia car park 
ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");
       gotoxy(8,4);
       cprintf("º                    ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ                 
º");
       gotoxy(8,5);
       cprintf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
       textcolor(WHITE);
       gotoxy(25,8);
       cprintf("Car park Management System");
       printf("\n\t\t\t\t-By issac Mugo,Otieno Brian");
       printf("\n\n\tThe System Manages Addition Of New Cars And Members");
       printf("\n\tAnd Also Keep Records Of Transactions Such As");
       printf("\n\tAllow Or exit Of A Cars With Fine");
       printf("\n\tRenew Existing Member Or Issue Duplicate ID");
       printf("\n\n\tThe Car Is Allowed For 1 Month ");
       printf("\n\tThe Membership Expires Aft.1er 6 Months");
       printf("\n\tThe Car Id Is Of The Format year+groupno+no");
       gotoxy(9,20);
       textcolor(LIGHTMAGENTA);
       cprintf("Send your comments/queries to ");
       textcolor(LIGHTGREEN+BLINK);
       cprintf("brianrombo@gmail.com");
       getch();
}

// when i run this code using c++ i get the following 2 errors at the points i have underlined above

: error C2143: syntax error : missing ';' before 'constant'
: fatal error C1004: unexpected end of file found
Error executing cl.exe.

Do you mind looking at announcement of the forum.

: error C2143: syntax error : missing ';' before 'constant'
: fatal error C1004: unexpected end of file found
Error executing cl.exe.


1st: You need to add a ; somewhere. I have no clue where, but it's somewhere above defining a constant

2nd: You did not include <stdafx.h>

FILE * fm = fm.1;

This line contains the first declaration of fm that I can see, as an instance of the type FILE *. However, fm.1 implies that there is a struct callled fm some place and you want to initalize the FILE * called fm with the value of the 1 member of the fm struct. How can you initialize something to itself? I suspect you want something like:

FILE * fm = fopen("member.dat","a+");

which means initialize the FILE * called fm with the address returned from fopen() after opening the file called member.dat in append mode using C style file handling.

2nd: You did not include <stdafx.h>

stdafx.h isn't part of standard C++, it's something which MSVC++ uses for precompiled headers.

Closed. Replies [thread=53570]here[/thread].

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.