Question
PLS help me !!! you will write C program that inputs lines from files where each line is in the following format: rank Male name
PLS help me !!!
you will write C program that inputs lines from files where each line is in the following format: rank Male name Male number Female name Female number where, rank The ranking of the names on this line Male name A male name of this rank Male number Number of males with this name Female name A female name of this rank Female number Number of females of this rank This is the format of database files obtained from the U.S. Social Security Administration of the top 1000 registered baby names (https://www.ssa.gov/OACT/babynames/index.html). Each line begins with the rank, followed by the male name at that rank, followed by the number of males with that name, etc. Here is a part of an example file containing data from the year 2017. You may assume the fields are tab separated. 1 Liam 18728 Emma 19738 2 Noah 18326 Olivia 18632 3 William 14904 Ava 15902 4 James 14232 Isabella 15100 5 Logan 13974 Sophia 14831 ... ... ... Your program will be given one or more filenames as commandline arguments that contain popular names from different years. The filenames will be in the form namesYYYY.txt where YYYY denote the year the data is from. E.g. names1998.txt will contain data from 1998. Your program should read in the data from the input files and store in an appropriate array of structures. You should define an appropriate structure to store information related to a specific name. For example a structure may look like this (add additional members you you need them) struct popularName { char *name; int rank; int number; char type; // M or F for male or female }; All arrays and strings must be dynamically allocated. For example, the member name in above structure must contain the address of a dynamically allocated string (just large enough to contain the input name, not any larger.) Here are the possible options your program must perform. Assume your executable is called hw. -s target-name Add the flag -s target-name, so that your program will print the statistics for the given target-name in the given files. For example: hw -s mary names1900.txt names2000.txt will print out the rank, number and percentages of mary in 1900, 2000, as well as the combined total statisticss of these two years. -v target-name If the flag -v target-name is given your program should find all variations of a name (all names that contain target-name as a substring) and print the proper statistics. For example, given John, there may be Johnnie, Johnathan, etc. -v overwrites -s, if both were given. Similar to -s, statistics should be printed for each given file separately as well as the total. -f List top 25 female names over all files alphabetically sorted, and with no repetitions. Also print the proper statistics for each name. -m List top 25 male names over all files given alphabetically sorted, and with no repetitions. Also print the proper statistics for each name. Above four flags may come together with three possible extra flags. 2 -r Adding the flag -r should print out only the rank of the name searched. For example, hw -s mary -r names1900.txt names2000.txt will print out only the rank of mary in 1900, 2000, as well as the total rank over these two years. -n Adding the flag -n should print out only the usage number of the name searched. -p Adding the flag -p should print out only the percentage of the name searched. Flags -n, -p and -r can combine at will and come in any order, i.e. -r -n -p is equivalent to -n -p -r, or -npr or -nrp, etc. Any or all of them may be omitted. If no flags are given, default is -rnp. You may assume that the list of file names is always last, i.e. the first non-flag argument you encounter is assumed to be the beginning of the list of file names. However, the flags themselves may come in any order. Make sure you error-check your arguments thoroughly, i.e. illegal/badly-formated options, non-existent options. Remember that some flags are optional (-r), some are not (one of -s or -v should appear), and the order of flags do not matter.
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