i want to delete an element of array structure to use it again to more understand look to the part of this code

struct patient

{
	int ID;
	 char name[100];
	 float age;
	 char sex[7];
	 char adress[100];
	 char hometelephone[12];
	 char mobiletelephone[11];
	 char workingtelephone[12];
	 char date[12];
	 char time[13];

} patients[100];
void delet()
{
int ida;
cout<<"Enter your Id"<<endl;
cin>>ida;
/* i want to delete this patient
patients[ida].name=0;
patients[ida].age=0;
patients[ida].id=0;
patients[ida].sex=0;
patients[ida].hometelephone=0;
patients[ida].workingtelephone=0;
patients[ida].mobiletelephone=0;
patients[ida].date=0;
patients[ida].time=0;
*/
}
Member Avatar for iamthwee

Can you use vectors or stacks?

NO it must be used array of structure

Member Avatar for iamthwee

Awww that's a shame.

Either move all other patients down one position or make an array of pointers to patients and allocate them dynamically. Then you can delete the patient at a certain position and mark the position as free by setting the pointer to 0.
Since your array seems to play a double role of also acting as a id->patient map, the latter is probably the better solution.

Of course, you could just use a real map.

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.