
Patrick B. answered 05/24/21
Math and computer tutor/teacher
void deletePhone(SmartPhoneType mobileList[], int size, int phoneID)
{
int iIndexPos=-1;
int iLoop=0;
//locates the phone rec with the specified id
for (iLoop=0; iLoop<size; iLoop++)
{
if (mobileList[iLoop].phoneID == phoneID)
{
iIndexPos=iLoop; //found it!!!
break;
}
}
if (iIndexPos>-1) //it is there
{
//moves each phone rec one position to the left, clobbering the target record
for (iLoop=iIndexPos; iLoop<size-1; iLoop++)
{
memcpy(&mobileList[iLoop],&mobileList[iLoop+1],SMART_PHONE_SIZE);
}
memset(&mobileList[size-1],0,SMART_PHONE_SIZE); //invalidates the last record
}
size--;
/* NEXT, you have to write this array containing size-1 records to the file, whose name is
neither specified, nor passed */
}