Question: 1. String Utilities In this exercise you will implement several utility functions involving strings. You will place all of your function prototypes in a header

1. String Utilities

In this exercise you will implement several utility functions involving strings. You will place all of your function prototypes in a header file named string utils.h and all of your function definitions in a source file named string utils.c.

You should implement your own main test driver program to test your functions, but you need not hand it in.

a. void addChar(char *str, char c, int n)

- this function should add a char c at index n in string str. The following characters should be shifted up to make room for the inserted character.

For example, a call to this function on the string Hello World, p, 4, would result in the string Hellpo World

b. int numChar(const char *src, char c) - this example determines the number of character c appears in the string. It does not

matter if the letter in the string is capitalized or not. For example, a call to this function on the string HellO World, o, would return 2.

c. int isPalindrome(const char *src) - this example determines if the string src is a palindrome or not. Return 1 if the string

is a palindrome and 0 if not. For example, a call to this function on the string testset, will return 1

d. int strCompare(const char *str, const char *str2)

- Write your own string comparison function that compares two strings for equality. You cannot use the < string.h > string comparison functions. Make sure the compare function is case insensitive. Return 0 if the two strings are equal and 1 if they are not.

For example, a call to this function on the string Hello world, and Hello World will return 0.

e. char* strCat(char *str, char *str2)

- Concatenate the two strings str and str2 and store that in a newly created dynamic string. The function should return this dynamic string. You cannot use the < string.h > concatenation functions.

For example, a call to this function on the string Hello, and World will return a dynamically created string that contains Hello World.

f. void consonantVowel(char *str) - This function will print out the number of consonants and vowels in the string. Note:

printing should be done in the function (notice the return type is void).

For example, a call to this function on the string Hello, will print Consonants: 3, Vowels 2.

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 Databases Questions!