So a user inputs an artist name, and then if the input matches one of the nodes containing the artist names i need to return that. but then also if the input does not match any of the nodes, I need to insert a new one. I have some lame attempt below, any guidance to fix it up would be fantastic. This is to be written in C
Also my structure that this function goes off of is shown below as well.
Code:artistNodePtr findOrInsertArtist( artistNodePtr *sPtr, char *artistID ) { artistNodePtr newNodePtr; temp = sPtr if(temp->artistName_p == artistID){ return temp }else{ newNodePtr = (artistNodePtr) malloc(sizeof(sPtr) } }Code:struct artist { char *artistName_p; struct disc *disc_p; struct artist *nextArtist_p; }; typedef struct artist artist_t; typedef struct artist *artistNodePtr;




Reply With Quote