Question: Linux and C In this question you will write a simple function for determining the length of a C string in three different ways. We
Linux and C

In this question you will write a simple function for determining the length of a C string in three different ways. We have provided a skeleton C file and Makefile to get you started. Download them and place them in a new subdirectory. Within the skeleton C file, a main function has been provided for you. Your job is to implement the 3 functions declared in the function prototypes at the beginning of the file. Add your function implementations below the main function. Make sure to test your resultant program The functions you need to write are as follows int strlen_iter char* string This function calculates the length of a string iteratively using some sort of loop int strlen_recursive return char* string This function calculates the length of a string by recursively calling itself with a substring (of the original string) which is one character shorter. It then returns a value of one plus the length of the substring. int strlen_recursive global char* string, int accum This function calculates the length of a string by calling itself recursively on a substring one character shorter than the original string and the second argument incremented by one. That is, the recursive call of the function will be strlen recursive global( stringt1, accumtl . On reaching the base case, the function will not make a recursive call. Instead it will store the value of the second function argument, accum, in the global variable global count. The function returns 1 (true) on successful operation, and 0 (false) on error. For this question, hand in your commented source code in string_length.c and an annotated test log. Instead of an annotated test log, you can submit a raw test log (no annotations) and a separate file with testing documentation (e.g. test plan, results description, conclusion) Notes o Keep the function prototypes at the top of the file and implement the functions below main) o Everything has been provided for you in the the skeleton C file. You only need to implement the functions. Do not modify the original code in any way o You don't need to include any other header files. o You shouldn't need to modify your Makefile. Just use the make command; i.e. make sure that your current working directory is the one with the Makefile provided and type the command "make". If compilation was successful, a binary called a.out will be created in your local directory To test your program, use commands of the form ../a. out string" where string s an arbitrary string; for example, ./a.out 'testing 1 2 3 Make sure to try a variety of strings, including the null string, and check that the answer given by your program in each case is correct
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
