CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 52

Threaded View

  1. #1
    Join Date
    Feb 2012
    Posts
    68

    Structure Linked Lists: Searching for Words.

    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;
    Last edited by chucker; April 8th, 2012 at 05:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured