Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PLEASE !!!!!!!!

Status
Not open for further replies.

lloyd1314

Programmer
Aug 23, 2001
3
GB
how do i add remove and display using an array or struct???
 
If you have an array of structs, initialize all the structs in the array to some value you know to be non-valid. You can put a constructor in the struct:

struct example{
int x;
int y;
int z;
example():x(-1),y(-1),z(-1){}

// for output using cout

friend ostream& operator <<(ostream& o, example e)
{
o<<e.x<<endl<<e.y<<endl<<e.z<<endl;
return o;
}

};


for the output you can set it to only output when x != -1 y != -1 etc


To remove them from the array

[1][2][3][4][5][6][7]

say you want to get rid of 4

shift 5 6 and 7 left so the new result will look like
1 2 3 5 6 7 and make sure to set the old 7 to all -1's

Matt
 
could you please show me some more examples, i have to add remove and display vehicles from file. thankyou so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top