Question
Instructions You will use the provide code skeleton to complete the assignment. The code skeleton consist of three files. These three files are main.c, xstring.c
Instructions You will use the provide code skeleton to complete the assignment. The code skeleton consist of three files. These three files are main.c, xstring.c and xstring.h. The main.c conatins the main program that allows the user to enter any string and characters to manipulate using the xstring library. The xstring.h file contains the function prototypes of the xstring library. Finally, the xstring.c file contains the implementation (function definition) of the xstring library. You are required to: 1. Complete the implementation of the functions in the xstring.c file
2. Link the main.c file and the xstring.c file using the xstring.h file
3. Compile and run the main to test your implementation
/* * Use this file to complete the implementation of the xstring library */ int FindFirstOccurrence(char c , char *pStr ){ } int FindLastOccurrence(char c, char *pStr ){ } int GetStringWeight (char *pStr ){ } void ReplaceCharacter(char x, char c , char *pStr ){ } // You could use (call) this function to help you implement the RemoveCharacter function // Make sure that DeleteChartAt keep the char array a valid C String ends with '\0' void DeleteCharAt(int index, int size, char array[]){ if(index < 0 || index >size -1) return; for(int i=index; i < size-1; i++){ array[i] = array[i+1]; } } void RemoveCharacter(char c, char str [] ){ } void ReverseString(char *pStr){ } void ToUpperCase(char *pStr){ } void ToLowerCase(char *pStr){ }
_____________________________________________________________________________________________________________________
#includeint main() { char test [150]; char c; char x; printf("Please enter a string of characters: "); scanf("%[^ ]s", test); printf("Please enter a character to test the function Find First Occurrence: "); scanf(" %c", &c); printf("The first occurrence of %c in %s is at index = %d ", c, test, FindFirstOccurrence(c, test)); printf("Please enter a character to test the function Find First Occurrence: "); scanf(" %c", &c); printf("The last occurrence of %c in %s is at index = %d ", c, test, FindLastOccurrence('o', test)); printf("The weight of the C String %s is = %d ", test, GetStringWeight(test)); ToUpperCase(test); printf("The uppercase version is = %s ", test); ToLowerCase(test); printf("The lowercase version is = %s ", test); ReverseString(test); printf("The reversed version is = %s ", test); printf("Please enter the character you want to replaced when test the function Replace Character: "); scanf(" %c", &x); printf("Please enter the new character you want insert when test the function Replace Character: "); scanf(" %c", &c); ReplaceCharacter(x, c, test); printf("The new C String after deleting %c is %s ", c, test); printf("Please enter the character you want remove when test the function Remove Character: "); scanf(" %c", &c); RemoveCharacter(c, test); printf("%s ", test); return 0; }
__________________________________________________________________________________________________________
#ifndef ASSIGNS_XSTRING_H #define ASSIGNS_XSTRING_H int FindFirstOccurrence(char , char * ); int FindLastOccurrence(char , char * ); int GetStringWeight (char * ); void ReplaceCharacter(char , char , char * ); void ReverseString(char *); void ToUpperCase(char *); void ToLowerCase(char *); void RemoveCharacter(char , char [] ); #endif //ASSIGNS_XSTRING_H
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started