Define a function called copyLine that takes one argument that is an input stream. When called, copyLine reads one line of input from the input stream given as its argument and writes that line to the screen. You should be able to call your function using either cin or an input-file stream as the argument to your function copyLine. (If the argument is an input-file stream, then the stream is connected to a file before the function is called, so copyLine will not open or close any files.) For example, the first of the following two calls to copyLine will copy a line from the file stuff.dat to the screen, and the second will copy a line from the keyboard to the screen:
ifstream fin;
fin.open(“stuff.dat”);
copyLine(fin) ;
copyLine(cin) ;
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Database Concepts (7th Edition)
Database Concepts (8th Edition)
Experiencing MIS
Starting Out with C++: Early Objects
Concepts Of Programming Languages
Starting Out With Visual Basic (7th Edition)
- in C program pleasearrow_forwardpythonarrow_forwardWrite a function count_character(filename, character) that takes in a filename and a character, both as strings, and returns the total number of times the given character occurs in the file. Examples: Contents of hello.txt:HelloHELLOHelloHELLO count_character('hello.txt', 'L') returns 4count_character('hello.txt', 'H') returns 4count_character('hello.txt', 'e') returns 2 Requirements: Please use Python Programming only Show screenshot of your work.arrow_forward
- P7arrow_forwardGiven a text file containing the availability of food items, write a program that reads the information from the text file and outputs the available food items. The program should first read the name of the text file from the user. The program then should read the text file, line by line. If a food is available, the program should output the available food item in the following format: name (category) -- description Assume the text file contains the category, name, description, and availability of at least one food item, separated by a tab character ('\t'). Hints: Use the find() function to find the index of a tab character in each row of the text file. Use the substr() function to extract the text separated by the tab characters. Ex: If the input of the program is: food.txt and the contents of food.txt are: Sandwiches Ham sandwich Classic ham sandwich Available Sandwiches Chicken salad sandwich Chicken salad sandwich Not available Sandwiches Cheeseburger Classic cheeseburger Not…arrow_forwardLet A and B two text files, containing some binary lines between of length 1...N. Where N is the line with the maximum number of characters, 1 the minimum number of characters in each line. Design a Python3 function to compare each line of the files, character by character, and if there is a match of the characters, create a variable representing the similarity between the lines of each file, and return that similarity variable measures the similarity between two files.arrow_forward
- Write a function named repeat_words that takes two string parameters: 1. in_file: the name of an input file that exists before repeat_words is called 2. out_file: the name of an output file that repeat_words creates Assume that the input file is in the current working directory and write the output file to that directory. For each line of the input file, the function repeat_words should write to the output file all of the words that appear more than once on that line. Each word should be lower cased and stripped of leading and trailing punctuation. Each repeated word on a line should be written to the corresponding line of the output file only once, regardless of the number of times the word is repeated. For example, if the following is the content of the file catInTheHat.txt: Too wet to go out and too cold to play ball. So we sat in the house. We did nothing at all. So all we could do was to Sit! Sit! Sit! Sit! The following function call: inF = 'catInTheHat.txt' outF =…arrow_forwardStart by writing a function, plot_grades (filename, first_name, last_name), which plots the grades for the specified student. This will be very similar in nature to what you did in Assignment 5.2 but will use the csv library instead of split (). a. The function should find the specified student in the file associated with filename. b. It should use plotter to plot all of the graded items for that student. c. Manually test your function using the full grades_ XXX.csv files.arrow_forwardWrite a function called max_age(inFile, outFile, breed) for a (python program), that takes three strings as input parameters. The function reads all the data from the inFile (1st input parameter) and writes data to the outFile (2nd input parameter) as described below. Each line in the input file represents a pet record and has the following format. name, breed, age where name and breed are strings, and age is an integer value. Your function must find the oldest pet of a given breed (3rd input parameter) from the inFile and write the following information to the outFile. breed, total records of this breed name of the oldest pet, age of the oldest pet Note that outFile must only have these two lines of information. Suppose, inFile contains the following data: shadow, longhair, 3 poshi, bangal, 5 mikus, longhair, 4 tigger, calico, 9 If you call this function with breed = "longhair", then the following must be written in the outFile: longhair, 2 mikus, 4 Your…arrow_forward
- Write a C++ function (along with helper functions if required) that takes a file stream as a parameter and prints out the maximum negative number in the given file. Do not need to write the main function. An example: [Example file contents] 4 -2 8 12 -8 9 3Prints: Maximum Negative number -2arrow_forwardWrite a C-language program that will satisfy the following: The program can read a text file named input.txt. This file contains the text of a news article consisting of at least 100 words. The program asks the user to input a word. The program reads the contents of the text file and counts how many times the inputted word appears. The program also determines how sentences there are in the file. Assume that every sentence is terminated by a period. the main() function should only contain variable declarations and functions calls. This means that you have to implement program functionality using user-defined functions.arrow_forwardWrite a small program that copies everything in a tet file to another file. The text file is calledin.txt and the output file is called out.txt. Two files should be exactly the same after copying(the first file shouldn’t be changed, and the second file should be the same as the first one).Your program should define a function called copyFile to copy the input file to the output filewith two arguments: a file pointer to the input file and a file pointer to the output file. You shouldnot and do not need to use an array during copying.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr