int delete_user(const char *name, User **user_ptr_del) {
    User *currUser = *user_ptr_del;
    if (currUser==NULL){
        return 1;
    }
    if(strcmp(currUser->name,name)==0){
        //delete the first user
        
        *user_ptr_del = currUser->next;
        free_user(currUser);
        return 0; 

    }
    while (currUser -> next != NULL){
        if(strcmp((currUser->next)->name,name)==0){
            free_user(currUser->next);
            currUser->next= (currUser->next)->next;
            
            return 0;
        }
        currUser = currUser->next;
    }
    
    return 1;
}


/*
 * frees the user pointed to by currUser from the
 * heap and all its attributes.
 */

void free_user(User *currUser){
//iterate to free all posts
        Post *currpost = currUser->first_post;
        Post *currpost2 = currUser->first_post;
        while(currpost!= NULL){
            currpost2 = currpost;
            currpost = currpost->next;
            //free contents, date and post 
            free(currpost2->contents);
            free(currpost2->date);
            free(currpost2);
            // currpost2 = currpost;
            // free(currpost);
            // currpost = currpost2->next;
        }

        //free the user from its friends' friend arrays
        for (int i=0; i<MAX_FRIENDS;i++){
            User *friend = (currUser->friends)[i];
            if (friend!=NULL){
                for (int j=0; j<MAX_FRIENDS;j++){
                    User *current = (friend->friends)[j];
                    if (current!=NULL && strcmp(current->name, currUser->name)==0){
                    (friend->friends)[j] = NULL;
                }
                }
            }
        }
        free(currUser);
}

remove user with name name from user_ptr_del