Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ LINEAR LINK LIST You will create a main.h and a main.cpp file for this Lab. In the main.h file include the following struct declaration

C++ LINEAR LINK LIST

You will create a main.h and a main.cpp file for this Lab. In the main.h file include the following struct declaration

image text in transcribed

for the element struct. This is your linked list element.

Your main.cpp program will store all of its command line arguments (the elements in the argv array) in a linked list of element. Your program will need a list head pointer: element * head; that points to the first element of the list. All elements in the list should be dynamic variables created by a new command.

  1. For each command line argument:
    1. Store the command line argument in a new element variable
    2. Append the element to the end of the linked list
  2. After loading the list, display the contents of the list
  3. Prompt the user for a word to delete from the list
  4. Remove the word from the linked list.
  5. Display (again) the list - the target word should no longer be in the list

Your program must avoid any memory leaks - be sure to delete anything you created before the program ends! Here is an example of how your program should behave:

image text in transcribed

// Element struct struct element std::string word; *next // Word to save // Next pointer element syccuxas01> main this is a test of lab 5 ord "main" ord "this" ord "is" Nord "a" = ord "test" ord"of" ord "1ab" Word - "5" Enter word to delete: main "main" deleted from the 1ist: ord "this" ord "is" Nord "a" = ord "test" Nord "of" = Nord = "lab" ord"5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago