Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2: Using the linked list library for strings ------------------------------------------------- In this part, you will use the linked list library that you implemented in part1

Part 2: Using the linked list library for strings -------------------------------------------------

In this part, you will use the linked list library that you implemented in part1 to write a program called 'revecho' that simply prints out the command line arguments in reverse order. In addition, it will look for the word "dude" (case-sensitive) among the command line arguments you passed, and report whether it's there or not.

For example,

./revecho hello world dude dude world hello

dude found

Another example:

./revecho hello world friend friend world hello

dude not found

Here are the program requirements and hints:

- Your program should simply put all the argument strings into a list WITHOUT duplicating them. There should be no malloc in your code. Just call addFront() for all strings.

- To print out the strings, you can either use traverseList() or you can traverse the list by yourself by following the next pointers, printing out each string. - Don't forget to initialize the list and remove all nodes at the end to prevent memory errors or leaks. Make sure you include valgrind output in your README.txt.

- To find 'dude', you can either traverse the list yourself, or use findNode(). Either way, strcmp() function will come in handy. If you want to pass strcmp to findNode(), you will have to cast it to the correct function pointer type because the signature of strcmp() is slightly different from the signature of 'compar' argument of findNode(). K&R2 section 5.11 has an example of casting a function pointer.

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions