Compare the word with the string and call itself to read

Assignment Help C/C++ Programming
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.

Reference no: EM132080182

Questions Cloud

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.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd