Hi..
i wanted to make a project for my 12th boards and i chose the topic "Parking Lot Administration". I had started writing all the functions and everything.. but i needed it in BINARY FILE.. n i dont know how to do it..
MY ROUGH CODING IS GIVEN BELOW :

#include<iostream.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

class vehicle
{  char vehno[15];
   char typ;
   int time;
   int level;
   public:
   int parking_lot_no;
   void enter_details(int a)
   { int a;
     cout<<"enter the type of vehicle:"<<endl;
     gets(typ);
     cout<<"enter the vehicle no:"<<endl;
     gets(vehno);
     cout<<"enter the time of entering (in 24 hr clock):"<<endl;
     cin>>time;
     cout<<"enter the parking level:"<<endl;
     cin>>level;
     parking_lot_no=a;
     cout<<"parking lot no.:"<<a;
   }
   void show_details()
   { cout<<"type of vehicle:"<<typ<<endl;
     cout<<"vehicle no."<<vehno<<endl;
     cout<<"time of entering:"<<time<<endl;
     cout<<"parking level:"<<level<<endl;
     cout<<"parking lot no.:"<<prking_lot_no<<endl;
   }
}

vehicle objE[10000],objD[7000],objC[6000],objB[5000],objA[4000];

void vehicle_entering()
{ char type;
  cout<<"two wheelers : E"<<endl;
  cout<<"small sized cars : D"<<endl;
  cout<<"medium sized cars : C"<<endl;
  cout<<"luxury cars : B"<<endl;
  cout<<"SUVs : A"<<endl;
  cout<<"enter the type of vehicle"<<endl;
  gets(type);
  if(type==E)
     E1();
  if(type==D)
     D1();
  if(type==C)
     C1();
  if(type==B)
     B1();
  if(type==A)
     A1();
}

 void vehicle_leaving()
{ char type;
  cout<<"two wheelers : E"<<endl;
  cout<<"small sized cars : D"<<endl;
  cout<<"medium sized cars : C"<<endl;
  cout<<"luxury cars : B"<<endl;
  cout<<"SUVs : A"<<endl;
  cout<<"enter the type of vehicle"<<endl;
  gets(type);
  if(type==E)
     E2();
  if(type==D)
     D2();
  if(type==C)
     C2();
  if(type==B)
     B2();
  if(type==A)
     A2();
}

void E1()
{ int space,count=0,i=1,v=0,cv=0;
  char ans;
  do while
  { space=10000-(i-1);
    for(int j=1;j<10001;j++)
    { if(objE[j].parking_slot_no==0)
      { v=j;
	count=count+1;
      }
    }
    if(space==0&&count==0)
       cout<<"parking lot full"<<endl;
    else
       if(count>0)
	 { objE[v].enter_details(v);
	   cv=cv+1;
	 }
       if(count==0)
	 { int f=i-cv;
	   objE[f].enter_detail(f);
	 }
    i=i+1;
    cout<<"Do you want to continue(y/n)?";<<endl;
    gets(ans);
  }(ans==y);
}

void D1()
{ int space,count=0,i=1,v=0,cv=0;
  char ans;
  do while
  { space=7000-(i-1);
    for(int j=1;j<7001;j++)
    { if(objD[j].parking_slot_no==0)
      { v=j;
	count=count+1;
      }
    }
    if(space==0&&count==0)
       cout<<"parking lot full"<<endl;
    else
       if(count>0)
	 { objD[v].enter_details(v);
	   cv=cv+1;
	 }
       if(count==0)
	 { int f=i-cv;
	   objD[f].enter_detail(f);
	 }
    i=i+1;
    cout<<"Do you want to continue(y/n)?";<<endl;
    gets(ans);
  }(ans==y);
}

void C1()
{ int space,count=0,i=1,v=0,cv=0;
  char ans;
  do while
  { space=6000-(i-1);
    for(int j=1;j<6001;j++)
    { if(objC[j].parking_slot_no==0)
      { v=j;
	count=count+1;
      }
    }
    if(space==0&&count==0)
       cout<<"parking lot full"<<endl;
    else
       if(count>0)
	 { objC[v].enter_details(v);
	   cv=cv+1;
	 }
       if(count==0)
	 { int f=i-cv;
	   objC[f].enter_detail(f);
	 }
    i=i+1;
    cout<<"Do you want to continue(y/n)?";<<endl;
    gets(ans);
  }(ans==y);
}

void B1()
{ int space,count=0,i=1,v=0,cv=0;
  char ans;
  do while
  { space=5000-(i-1);
    for(int j=1;j<5001;j++)
    { if(objB[j].parking_slot_no==0)
      { v=j;
	count=count+1;
      }
    }
    if(space==0&&count==0)
       cout<<"parking lot full"<<endl;
    else
       if(count>0)
	 { objB[v].enter_details(v);
	   cv=cv+1;
	 }
       if(count==0)
	 { int f=i-cv;
	   objB[f].enter_detail(f);
	 }
    i=i+1;
    cout<<"Do you want to continue(y/n)?";<<endl;
    gets(ans);
  }(ans==y);
}

void A1()
{ int space,count=0,i=1,v=0,cv=0;
  char ans;
  do while
  { space=4000-(i-1);
    for(int j=1;j<4001;j++)
    { if(objA[j].parking_slot_no==0)
      { v=j;
	count=count+1;
      }
    }
    if(space==0&&count==0)
       cout<<"parking lot full"<<endl;
    else
       if(count>0)
	 { objA[v].enter_details(v);
	   cv=cv+1;
	 }
       if(count==0)
	 { int f=i-cv;
	   objA[f].enter_detail(f);
	 }
    i=i+1;
    cout<<"Do you want to continue(y/n)?";<<endl;
    gets(ans);
  }(ans==y);
}

void E2()
{ int pkln;
  cout<<"enter parking lot no."<<endl;
  cin>>pkln;
  for(int i=1;i<10001;i++)
  { if(objE[i]==pkln)
       objE[i].show_details;
  }
  cout<<"Amount to be charged Rs.5"<<endl;
  cout<<"vehicle is cleared to leave"<<endl;
}

void D2()
{ int pkln;
  cout<<"enter parking lot no."<<endl;
  cin>>pkln;
  for(int i=1;i<70001;i++)
  { if(objD[i]==pkln)
       objD[i].show_details;
  }
  cout<<"Amount to be charged Rs.10"<<endl;
  cout<<"vehicle is cleared to leave"<<endl;
}

void C2()
{ int pkln;
  cout<<"enter parking lot no."<<endl;
  cin>>pkln;
  for(int i=1;i<10001;i++)
  { if(objC[i]==pkln)
       objC[i].show_details;
  }
  cout<<"Amount to be charged Rs.20"<<endl;
  cout<<"vehicle is cleared to leave"<<endl;
}

void B2()
{ int pkln;
  cout<<"enter parking lot no."<<endl;
  cin>>pkln;
  for(int i=1;i<10001;i++)
  { if(objB[i]==pkln)
       objB[i].show_details;
  }
  cout<<"Amount to be charged Rs.40"<<endl;
  cout<<"vehicle is cleared to leave"<<endl;
}

void A2()
{ int pkln;
  cout<<"enter parking lot no."<<endl;
  cin>>pkln;
  for(int i=1;i<10001;i++)
  { if(objA[i]==pkln)
       objA[i].show_details;
  }
  cout<<"Amount to be charged Rs.30"<<endl;
  cout<<"vehicle is cleared to leave"<<endl;
}


void main()
{ int ch;
  cout<<"1: vehicle entering"<<endl;
  cout<<"2: vehicle leaving"<<endl;
  cout<<"enter choice"<<endl;
  cin>>ch;
  if(ch==1)
     vehicle_entering();
  if(ch==2)
     vehicle_leaving();
  else
     { cout<<"incorrect choice, enter again"<<endl;
       cin>>ch;
     }
}

COULD Ne1 help m eout converting it to binary and modifying it a little bit so that it looks like a decent XIIth boards program..
plssssssss do sum1 help.. my carreer depends on this :(
PLSSSS HELP!!!
regards...
djsingh

>>COULD Ne1 help m eout
Huh??? is that Chinese or Japanese you are writing. Please write English.

>>converting it to binary
converting what to binary? Your program? All you have to do is use a compiler and compile it. The compiler will create the *.exe file (well, technically its the linker that does that.).

> I had started writing all the functions and everything
There's a saying which reads "hours spent thinking about the design can save months of coding". This applies here.

A prime example being why all your 'A' to 'E' objects and functions all look the same. There should only be one of each, and a parameter.

$ g++ foo.cpp
In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31,
                 from foo.cpp:1:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at
least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the
C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead
of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
foo.cpp: In member function `void vehicle::enter_details(int)':
foo.cpp:15: error: declaration of 'int a' shadows a parameter
foo.cpp:17: error: invalid conversion from `char' to `char*'
foo.cpp:17: error:   initializing argument 1 of `char* gets(char*)'
foo.cpp: In member function `void vehicle::show_details()':
foo.cpp:32: error: `prking_lot_no' undeclared (first use this function)
foo.cpp:32: error: (Each undeclared identifier is reported only once for each function it appears in.)
foo.cpp: At global scope:
foo.cpp:36: error: `vehicle' does not name a type
foo.cpp: In function `void vehicle_entering()':
foo.cpp:46: error: invalid conversion from `char' to `char*'
foo.cpp:46: error:   initializing argument 1 of `char* gets(char*)'
foo.cpp:47: error: `E' undeclared (first use this function)
foo.cpp:48: error: `E1' undeclared (first use this function)
foo.cpp:49: error: `D' undeclared (first use this function)
foo.cpp:50: error: `D1' undeclared (first use this function)
foo.cpp:51: error: `C' undeclared (first use this function)
foo.cpp:52: error: `C1' undeclared (first use this function)
foo.cpp:53: error: `B' undeclared (first use this function)
foo.cpp:54: error: `B1' undeclared (first use this function)
foo.cpp:55: error: `A' undeclared (first use this function)
foo.cpp:56: error: `A1' undeclared (first use this function)
foo.cpp: In function `void vehicle_leaving()':
foo.cpp:67: error: invalid conversion from `char' to `char*'
foo.cpp:67: error:   initializing argument 1 of `char* gets(char*)'
foo.cpp:68: error: `E' undeclared (first use this function)
foo.cpp:69: error: `E2' undeclared (first use this function)
foo.cpp:70: error: `D' undeclared (first use this function)
foo.cpp:71: error: `D2' undeclared (first use this function)
foo.cpp:72: error: `C' undeclared (first use this function)
foo.cpp:73: error: `C2' undeclared (first use this function)
foo.cpp:74: error: `B' undeclared (first use this function)
foo.cpp:75: error: `B2' undeclared (first use this function)
foo.cpp:76: error: `A' undeclared (first use this function)
foo.cpp:77: error: `A2' undeclared (first use this function)
foo.cpp: In function `void E1()':
foo.cpp:81: error: `void E1()' used prior to declaration
foo.cpp:84: error: expected `(' before '{' token
foo.cpp:84: error: expected primary-expression before '{' token
foo.cpp:84: error: expected `)' before '{' token
foo.cpp:86: error: `objE' undeclared (first use this function)
foo.cpp:103: error: expected primary-expression before '<<' token
foo.cpp:104: error: invalid conversion from `char' to `char*'
foo.cpp:104: error:   initializing argument 1 of `char* gets(char*)'
foo.cpp:105: error: expected `while' before '(' token
foo.cpp:105: error: `y' undeclared (first use this function)
foo.cpp: In function `void D1()':
foo.cpp:109: error: `void D1()' used prior to declaration
foo.cpp:112: error: expected `(' before '{' token
foo.cpp:112: error: expected primary-expression before '{' token
foo.cpp:112: error: expected `)' before '{' token
foo.cpp:114: error: `objD' undeclared (first use this function)
foo.cpp:131: error: expected primary-expression before '<<' token
foo.cpp:132: error: invalid conversion from `char' to `char*'
foo.cpp:132: error:   initializing argument 1 of `char* gets(char*)'
foo.cpp:133: error: expected `while' before '(' token
foo.cpp:133: error: `y' undeclared (first use this function)
foo.cpp: In function `void C1()':
foo.cpp:137: error: `void C1()' used prior to declaration
foo.cpp:140: error: expected `(' before '{' token
foo.cpp:140: error: expected primary-expression before '{' token
foo.cpp:140: error: expected `)' before '{' token
foo.cpp:142: error: `objC' undeclared (first use this function)
foo.cpp:159: error: expected primary-expression before '<<' token
foo.cpp:160: error: invalid conversion from `char' to `char*'
foo.cpp:160: error:   initializing argument 1 of `char* gets(char*)'
foo.cpp:161: error: expected `while' before '(' token
foo.cpp:161: error: `y' undeclared (first use this function)
foo.cpp: In function `void B1()':
foo.cpp:165: error: `void B1()' used prior to declaration
foo.cpp:168: error: expected `(' before '{' token
foo.cpp:168: error: expected primary-expression before '{' token
foo.cpp:168: error: expected `)' before '{' token
foo.cpp:170: error: `objB' undeclared (first use this function)
foo.cpp:187: error: expected primary-expression before '<<' token
foo.cpp:188: error: invalid conversion from `char' to `char*'
foo.cpp:188: error:   initializing argument 1 of `char* gets(char*)'
foo.cpp:189: error: expected `while' before '(' token
foo.cpp:189: error: `y' undeclared (first use this function)
foo.cpp: In function `void A1()':
foo.cpp:193: error: `void A1()' used prior to declaration
foo.cpp:196: error: expected `(' before '{' token
foo.cpp:196: error: expected primary-expression before '{' token
foo.cpp:196: error: expected `)' before '{' token
foo.cpp:198: error: `objA' undeclared (first use this function)
foo.cpp:215: error: expected primary-expression before '<<' token
foo.cpp:216: error: invalid conversion from `char' to `char*'
foo.cpp:216: error:   initializing argument 1 of `char* gets(char*)'
foo.cpp:217: error: expected `while' before '(' token
foo.cpp:217: error: `y' undeclared (first use this function)
foo.cpp: In function `void E2()':
foo.cpp:221: error: `void E2()' used prior to declaration
foo.cpp:225: error: `objE' undeclared (first use this function)
foo.cpp: In function `void D2()':
foo.cpp:233: error: `void D2()' used prior to declaration
foo.cpp:237: error: `objD' undeclared (first use this function)
foo.cpp: In function `void C2()':
foo.cpp:245: error: `void C2()' used prior to declaration
foo.cpp:249: error: `objC' undeclared (first use this function)
foo.cpp: In function `void B2()':
foo.cpp:257: error: `void B2()' used prior to declaration
foo.cpp:261: error: `objB' undeclared (first use this function)
foo.cpp: In function `void A2()':
foo.cpp:269: error: `void A2()' used prior to declaration
foo.cpp:273: error: `objA' undeclared (first use this function)
foo.cpp: At global scope:
foo.cpp:282: error: `main' must return `int'

OMG, did you even bother to compile the code like halfway through or anything? There are any number of copy/paste errors which should have been eliminated at the first instance, not replicated five times.

> my carreer depends on this
Your career can do without you if this is your approach to software development. We're not here to help you get a job you're incapable of, or keep a job you're incapable of performing.

http://www.catb.org/~esr/faqs/smart-questions.html#writewell

Nonononono......
I've to make the program using BINARY FILES...... i need same functions and all.. but in BINARY FILES[file management concept in C++] and then ill have to compile the way u sed

>>project for my 12th boards
we don't know what you mean by that.

>>program using BINARY FILES
Don't know exactly what you mean by that either. Do you want the vehicle data to be written to and read from a data file in binary format? You need to create an array (or c++ vector) of vehicle classes vector<vehicle> vehicleArray; then when done inputting the data write them all out to a file in their binary form

ofstream out("vehicles.dat", ios::binary);
vector<vehicle>::iterator it;
for(it = vehicleArray.begin(); it != vehicleArray.end(); it++)
{
    vehicle& v = *it;
    out.write(&v, sizeof(vehicle));
}

Reading the file on program startup is just as simple. Leave that up to you to write.

> >project for my 12th boards
> we don't know what you mean by that.
I thought it was some hardware module for a while, but it seems it's an Indian examination board, for what would appear to be 12th grade (in US terms).
It seems to be a useful step into getting to a university.

But the OP needs to fix all the systemic errors in their program before worrying about a minor detail as to whether the output file is text for binary.

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.