Question: Please answer the question by properly reading it and following the instructios. get_extention.c file This exercise is based on a combination of Exercise 12 from


This exercise is based on a combination of Exercise 12 from Ch 12 and Programming Project 18 from Ch 13. You are provided a file called get_extension.c that has the following function prototype: int get_extension(const char *file_name); where file_name is a string containing a file name. Your task is to implement this function as follows: The function processes the passed file name to find the file extension and returns the index of this file extension from a lookup array called extensions. The function must declare extensions as a static array of pointers to strings that stores the following file extensions in this exact order: . txt . out .bkp . dot . tx For example, if the input file name is memo, txt, the function will return 0 . If the file name is memo. tx. dot, the function will return 3. If the file name doesn't have an extension (or the extension is not in the array), the function will return -1. Keep the function as simple as possible by having it use functions from the string library such as strlen, strncpy, stremp, etc. To test your get_extension() function, the provided program's main() function takes the file name as a program argument and passes it to get_extension(). The main() function then prints the value returned by get extension() to stdout. You can safely assume that the program will always be provided with an argument. You do not need to do any argument validation for this exercise. You can assume that the file name will have at most 20 characters, including the extension. Files that need to be on GitHub: - part2/get_extension.c - part2/Makefile \#include \#define MAX_SIZE 20 int get_extension(const char *file_name); int main(int argc, char* argv[])\{ // simplifying things and not doing any argument validation printf("The index value of the extension of the input file is: %d ", get_extension(argv[1])); \}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
