Linked List Deletion function causing program to crash *wrong pointers?*
In my program when a username is following another one and also has posted a "tweet" which is a string in an attempt to delete the followed username it breaks the program. I believe this is the code snippet in question. If anyone could help me identify the issue I would be thankful as I am learning the usage of linked lists for scale able projects. Thanks
void deleteAccount(accountNodePtr *startPtr, accountNodePtr *curAcPtr, tweetsNodePtr *startTwtPtr){
accountNodePtr acLoopPtr;
accountNodePtr tempCur = *curAcPtr;
followNodePtr followingPtr = tempCur->followingPtr;
followNodePtr tempPtr;
followNodePtr tempPtr2;
tweetsNodePtr iterTwtPtr;
iterTwtPtr = *startTwtPtr;
*below here in question*
tempCur = *curAcPtr;
while (tempCur->followersPtr!=NULL){
acLoopPtr = *startPtr;
while (strcmp(acLoopPtr->username, tempCur->followersPtr->username)!=0){
acLoopPtr=acLoopPtr->nextPtr;
}
if (strcmp(acLoopPtr->followingPtr->username, tempCur->username)==0){
tempPtr=acLoopPtr->followingPtr->nextPtr;
free(acLoopPtr->followingPtr);
acLoopPtr->followingPtr=tempPtr;
}else{
tempPtr=acLoopPtr->followingPtr;
while(strcmp(tempPtr->nextPtr->username, tempCur->username)!=0){
tempPtr=tempPtr->nextPtr;
}
tempPtr2=tempPtr->nextPtr->nextPtr;
free(tempPtr->nextPtr);
tempPtr->nextPtr=tempPtr2;
}
tempPtr = tempCur->followersPtr->nextPtr;
free(tempCur->followersPtr);
tempCur->followersPtr=tempPtr;
}
This is the structure
typedef struct followsNode {
char username[MAX_USERNAME];
struct followsNode *nextPtr;
} followNode;
typedef struct accountsNode {
char username[MAX_USERNAME];
struct followsNode *followersPtr;
struct followsNode *followingPtr;
struct accountsNode *nextPtr;
} accountNode;
typedef followNode *followNodePtr;
typedef accountNode *accountNodePtr;
How many English words
do you know?
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
how many words do you know
Powered by Examplum