Reference no: EM132080182
You need some help writing this C code.
It is supposed to do this :
Here are some basic components for your program design.
First, your main program gets the file name (string) from the keyboard input, make sure that the file exists while opening the file. Specifically, your program asks "Please input the text file name:" Then it uses scanf to read the string from the keyboard, which is the file name for fopen. If the file does not exist, which means that fopen will return NULL instead of the pointer to the file, your program notify the user and quit.
Second, if the file exists, the main program asks for a word "Please input the word to search:". After receive the word from the keyboard, it calls search_and_count() to search the word and count the characters in the file. So search_and_count() will have the file pointer and the word as input, and an indicator (0 or 1) (whether the word is contained in the file) and the total number of characters ('A'-'Z' or 'a'-'z' that are in the file) as output. Your main program then reports whether the word exists in the file, and how many characters are in the file.
search_and_count() will read a string from the file, count the characters in the string, compare the word with the string (to see if the word exists in the file), and call itself to read the next string from the file until the end of the file, which is the exit condition of the recursion. Specifically, you will need to build two more functions:
search_and_count() reads a string from the file into a variable, call function character_count() to count the number of characters in the string, and then call function word_search() to compare the word with the string to decide whether it is a match. This will go on in a recursive call until the end of file. If there is a match already, it doesn't need the comaprison any more. In other words, word_search() will be called only if your program hasn't found a match.
character_count() should have an input, which is the current string, and a return value, which is the count of the number of characters in the string.
word_search() should have two input, the word and the string, and a return value 0 or 1 as an indicator whether the word is the same as the string. The program should allow the string has an ending punctuation. That is, you may want to put a NULL in the string to make it the same length as the word, so that you can use strcmp to compare the word with the string.
Finally, in the main program, close your file and report whether there is a match and how many characters are in the file.
A java program for the diffie-hellmann key exchange
: Compute and print the values of p, the generator g, random numbers a,b Z* p, and other intermediate results computed in the Dife-Hellman protocol.
|
Draw the bracket shown including centre
: ENGINEERING DESIGN - COMPUTER-BASED TECHNOLOGY - BASIC DRAWING - Draw the bracket shown below including centre lines but not the dimensions
|
Write the equation of an ellipse centered at the origin
: Steps to solve the following problem. Write the equation of an ellipse centered at the origin with foci at (0, -3) and (0, 3) and a major axis of 10.
|
Write an application that counts by three
: Write an application that counts by three from 3 through 300 inclusive, and that starts a new line after every multiple of 30.
|
Compare the word with the string and call itself to read
: In the main program, close your file and report whether there is a match and how many characters are in the file.
|
Prepare a simple computer program for a hardware store
: A hard ware store needs a program to showthe amount of original order, amount of any discounts, subtotal, amount of tax.
|
Acetic acid solution must be mixed
: What quantity of 64% acetic acid solution must be mixed with a 26% acetic acid solution to produce 1038.66 mL of 35% solution?
|
What height is the mass when it is first released
: A mass attached to a spring is at a height given by h(t) = 3 - ( 2 sin(t) / 1 + t^ 2)
|
Need an introduction about project integration simulations
: Need an introduction about project integration simulations for a software company lullnet corp. localisation of 3 languages to the international market.
|