Question: Please, write it in C programming language. Thanks. String is represented by a sequence of characters and should have a length property that shows the

 Please, write it in C programming language. Thanks. String is representedby a sequence of characters and should have a length property thatshows the number of characters stored in that string (excluding the nullcharacter). Suppose that this struct can be used to represent only thestrings with less than 50 characters. You should implement the following functions

Please, write it in C programming language. Thanks.

String is represented by a sequence of characters and should have a length property that shows the number of characters stored in that string (excluding the null character). Suppose that this struct can be used to represent only the strings with less than 50 characters. You should implement the following functions to operate on your String data type. int charAt(String *s, int index) This function should return the character stored at the location index. If there is no such an index (either negative index value, or greater or equal to the length of the string), then return -1. String *concat(String *s1, string *s2) o This function should concatenate the string pointed by s2 to the end of the string pointed by sl, and return the address of the new string. You cannot use strcat or strncat functions of string.h library of C in that function. unsigned int strSearch (String *s1, string *s2) This function should scan the first string and return the length of initial segments that contain only the characters of the second string. If there is no such a segment, return 0. You cannot use strspn or strcspn functions of string.h library of C in that function. unsigned int findScore (String *s1) o This function should return a score by checking the given String. To calculate the score, you will use the following table: Letter A, E, I, O, U, L, N, R, S, T D G B, C, M, P F, H, V, W, Y K J, X Value 1 2 3 4 5 8 10 Q, Z O For example, the String is hello should be scored as 4+1 + 2 + 1 + 1 = 8. Your program should continue to execute until the given word is either exit" or "quit. If the given word is exit" or "quit, your program should terminate. If the given word is stat, your program should print a two-line statistical report: the first line prints the total number of words the user has entered, and the second line prints the total number of alphabetic letters the user has entered. Note that we only count the 26 letters in the alphabet (either lower case or upper case). For example, if a user has entered the following string, i.e. We love CSE1142 course a lot!!", the following should be printed to screen after the user types stat": The number of words: 6 The number of alphabetic letters: 19 If the given word is not stat, exit or quit, then your program will continue to execute based on the user's selection. You have to perform File I/O operations in this homework. All the user options will be given using an input file that is passed to your program using command line arguments. All the outputs of your program must be printed to an output file that is passed to your program using command line arguments. o For example, suppose that input.txt" and "output.txt" are given to your program as command line arguments. o Each line of the input file contains the related operations followed by the specified options. o For example, if a line is as follows: hello world: 1,6 o For example, if a line is as follows: hello world: 1,6 Here, "hello world is the given string that we use. 1 represents that the operation is finding a char o 6 represents the index for the searched char. The output for this option should be w, which will be added to a given output file. The valid options given as the second argument (given after colon : ) can be 1 for finding a char in the given index, 2 for string concatenation, o 3 for string search, 4 for finding the string score. If the required operation needs a third option (given after comma , ) it can be O An index for finding a char in the given string, O A second string for string concatenation, O A second string for string search. An operation may not require a third option (For example, finding the string score), in such a case, you can directly find the score of the string. Suppose that the input file contains the following lines: hello world:1,6 Welcome to C:2, programming! welcome to marmara university!:3, mar We love CSE!!:4 stat exit . Then, the output file should contain the output of each operation as follows: W Welcome to c programming! 7 17 The number of words: 14 The number of alphabetic letters: 69 Program ends. Bye

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!