I need to implement a function which ads elements to a single linked list:
-if the head(first element) of the list doesn't exist(if head is NULL), then the added(inserted) element becomes the head(the the data entered is of string type)
-if the head already exists, insert it after the last element(for example |A|*->|B|*->NULL, after adding element C, the list looks like this: |A|*->|B|*->|C|*->NULL)
-the information member holds string type information(pointer to char to more precise)
CPT
0
Newbie Poster
Recommended Answers
Jump to PostWe're not going to do your homework for you.
(1) if the head is NULL -- this is a simple assignment statement. allocate memory for the new node then assign its pointer to the list's head.
(2) head already exists: You want to add the new node to …
Jump to PostThis tutorial might be helpful.
All 8 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
CPT
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
CPT
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
CPT
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.