codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  array of struct  agskanchana at 04:27 on Tuesday, February 09, 2010
 

hi there

i'm new to c++ and i hv been trying to make a little program
about adding vehicle details(ID,number,category, brand,price etc.) to a menu and displaying entered details,searching for a particular vehicle based on either vehicle number or category and deleting a record of sold vehicle.

following is the answer i could come up with



#include <iostream>
#include <string>

using namespace std;

struct vehicles

{

char vehicalid[8];
char vehicalnumber[8];
char category[10];
char brand[20];
int price;


} data[100];

int main ()
{
int d=0;
int i=0;
int op=0;
int n=0;
int b=0;
char num[8];


cout<<"option (1) add vehicle details \n";
cout<<"option (2) view view details \n";
cout<<"option (3) search for a vehicle \n";
cout<<"option (4) delete vehicle details \n"<<endl;

cout<<"option 01 \n"<<endl;

cout<<"enter your Option \n";
cin>>op;
loop:

while (op==1){

cout<<"enter vehicle ID \t";
cin>>data[n].vehicalid;
cout<<"enter vehicle number \t";
cin>>data[n].vehicalnumber ;
cout<<"enter vehicle category \t";
cin>>data[n].category;
cout<<"enter brand of the vehicle \t";
cin>>data[n].brand;
cout<<"enter price of the vehicle \t";
cin>>data[n].price;

n++;

cout<<"Enter Your Option to continue \t";
cin>>op;

if(op!=1)goto loop;

}

while (op==2){
cout<<"Option (2) \n";
while(b<n){
cout<<data.vehicalid<<'\t'<<data.vehicalnumber<<'\t'<<'\t'<<data.category<<'\t'<<data.brand <<'\t'<<data.price<<endl;
b++;
}
cout<<"Enter your option to continue \t";
cin>>op;
if(op!=2)goto loop;

}
while (op==3){
cout<<"Option (3) \n";

cout<<"enter vehicle number \n";
cin>>num;

while (i<n){
i++;
if(strcmp(data.vehicalnumber, num)==0) break;
}


cout<<"search resutl !! \n";
cout<<"vehicle id\t"<<"Number\t"<<"Category\t"<<"Brand\t"<<"price\n";
cout<<data.vehicalid<<'\t'<<data.vehicalnumber<<'\t'<<data.category<<'\t'<<data.brand<<'\t'<<data.price<<'\n';
cout<<"Enter your option to continue \t";
cin>>op;
if(op!=3)goto loop;

}



return 0;
}


i dont hv any idea how to delete details of a particular vehicle

and when first add vehicle details and go on to the second option to show detail it works fine but again if i try to add details of a vehicle and to see the details of all vehicle entered so far ,only latest details entered is shown

if someone can help me on this that would be really helpful
















CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Need to enter XML content into HTML formatted email document
•  Lightweight components reuses its parents graphical units. Heavyweight components
•  lightweight and heavyweight component
•  array of struct
•  matrix prblm in java
•  Re: how to open instantly a pop up window whenever a user sends a message to the other user
•  Re: PING PROGRAM IN PERL
•  Re: date of birth validation using java script-very urgent
•  JAVA If statements


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010