so after fixing that error. Here's what i have
Code:
void removePtr(LIST_ELEM *pHead, int loc){
LIST_ELEM *ptr;
LIST_ELEM *tmpPtr;
int size = sizeOf(pHead);
int i = 0;
for(ptr = pHead; ptr != NULL; ptr++){
if( loc == 0 && (size==0)){
tmpPtr = pHead;
pHead = ptr->pNext;
free(tmpPtr);
printf("The list is now empty.");
}
else if( loc == 0){
tmpPtr = pHead;
pHead = ptr->pNext;
free(tmpPtr);
}
else if( i == loc){
LIST_ELEM *ptrB4 = nodeB4(pHead,loc);
tmpPtr = ptr;
LIST_ELEM *ptrAfter = (tmpPtr->pNext);
ptrB4->pNext = ptrAfter;
free(tmpPtr);
}
i++;
}
}
Checking the first two cases gives me a seg fault and checking the last error gives me a
Code:
glibc detected *** a.out: free(): invalid pointer:
errror.
going home so I'll be back tomorrow =(