Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a C program called prog5.c that looks for words in a dictionary which have certain properties as described below. You should exhibit a proficiency

Create a C program called prog5.c that looks for words in a dictionary which have certain properties as described below. You should exhibit a proficiency in: Operations on Strings Dynamic Memory Allocation File Operations Using Command Line Arguments Calculating and Storing Statistics

The program should assume the standard QWERTY keyboard.

Input:

Your program is to input two command line arguments: the first is the path and name of the dictionary file, dictionary, and the second is the path and name of the output file, output_file, as given below.

prog5 dictionary output_file

Your program is to read in the contents of the dictionary provided into a dynamically allocated array of pointers to strings,

e.g. char *Words[NUM_WORDS]

so that the array requires the minimum amount of storage for each word.

Your program should examine those words and find which words have the following properties: 1. The longest word(s) typed only with the right hand. 2. The longest word(s) typed only with the left hand. 3. The longest word(s) typed with only the first letter row of the keyboard. 4. The longest word(s) typed with only the second letter row of the keyboard. 5. The longest word(s) typed with only the third letter row of the keyboard. 6. All words and longest word ending in dous. 7. All palindromes. (A palindrome is a word which is the same read backwards. e.g. kayak) 8. All words and longest word having all five vowels in order. 9. The percentage of time the left hand is used to type all dictionary words in order.

Output:

Your program should output the results of the searches listed above to both the screen, and the output file, output_file.

Further Considerations:

Your program should be structured neatly, easily readable, and well commented. Furthermore, variable and function names should be such that the software is as self-commenting as possible.

Use the following line to compile your program:

gcc -Wall -g prog5.c -o prog5

I really need help with the code for 1-9 in the bold text above.

The code I have for this program so far is:

#include #include #include #include

//Get line number function int GetLineNum(char * filename) { FILE * fp; char c; int NumofLine=0; int size = 0; int i = 0; char ** array; //Open the file fp = fopen(filename,"r"); //check if file exists if (fp == NULL) { printf("Could not open file %s", filename); return 0; } //Extract characters from file and store in character c for (c = getc(fp); c != EOF ; c = getc(fp)) { size++; if (c == ' ') { NumofLine++; } } array = (char **) malloc(NumofLine*sizeof(char *)); for(i = 0 ; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Model self-criticism of your own productions.

Answered: 1 week ago

Question

8. Explain the contact hypothesis.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago