Question: For this problem, you are to write four functions involving pointers, linked lists, character strings, and / or arrays, based upon the following definition: struct

For this problem, you are to write four functions involving pointers, linked lists, character strings, and/or arrays, based upon the following definition:
struct node {
char data;
struct node *next;
};
A. struct node * stringToList ( const char * inputString, int * length );
This function creates a linked list from the characters in the inputString, in either forward or reverse order.
The length variable should be set to the number of nodes in the completed linked-list.
The return value should be a pointer to the first node of the newly created list, or NULL if the list could not be completed for some reason.
Use a pointer variable to step through the input string, (which is terminated by a null byte.)
B. int insertCapsAfter ( struct node *head) ;
For every character in the linked list that is a lower-case alphabetic character, add a new node in the list following it that contains the upper-case equivalent.
The return value should be the number of new nodes added to the list.
C. int countChars ( struct node *head, const char searchList[], int counts[], int nChars );
For each char in searchList, this function counts how many times that char appears in the linked list, and stores that total in the corresponding location in the counts array. (Le. the number of times that searchList i] appears in the linked list should be stored in counts[ i]).
nChars is the length of the two arrays.
The return value should be the total sum of all the numbers stored in counts, or -1 if there is a problem that prevents the function from running.
You should first write a function
int countChar ( struct node *head, char c );
which counts the number of times the character c appears in the list. Then countChars should call countChar as many times as necessary to accomplish its task.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!