Question

C++ Xcode (mac) This program can open a text file and print its contents to the...

C++ Xcode (mac)

This program can open a text file and print its contents to the screen.For example, it could load the output.txt file generated in the previous program and display on the screen the textcontained in the file.

Homework Answers

Answer #1

ANSWER:--

GIVEN THAT:--

#include <iostream>
#include <fstream>

using namespace std;
  
int main()
{
ifstream fs;
  
//variable declartion
char ch;
  
//open file
fs.open("output.txt", ios::in);
  
//while loop
   while (!fs.eof() )
   {
   //display the character on the computer screen
   cout << ch;
   fs.get(ch);
   }
}

INPUT:

output.txt

hello hi
how are you
ok bye
done

OUTPUT:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++. This program can open a text file and print its contents to the screen. For...
C++. This program can open a text file and print its contents to the screen. For example, it could load the output.txt file generated in the previous program and display on the screen the text contained in the file.
Attached is a text file containing lots of randomly generated numbers in no particular order. Write...
Attached is a text file containing lots of randomly generated numbers in no particular order. Write a program that can open that file, sort the numbers from least to greatest, and display them in sorted order on the screen. The name of the text file is; numbers_fall2020.txt Please solve using C++ Thanks!
C# Reading from Files Write a program to open a text file containing information about buildings....
C# Reading from Files Write a program to open a text file containing information about buildings. The program must display all the buildings in the file and then find the lowest cost building based on the cost per square foot. Format for one building: <building name> <size> sqft $<cost> Example: Allgood Hall 35000 sqft $8,250,099.75 Create the text file and add three or more of your favorite buildings.
c# please Create a “Main” program which reads a text file called “collectionOfWords.txt”. Include exception handling...
c# please Create a “Main” program which reads a text file called “collectionOfWords.txt”. Include exception handling to check if the file exists before attempting to open it. Read and print each string to the console. Next modify each word such at the first letter in each word is uppercase and all other letters are lowercase. Display the modified word on the console. Creating a text file: Open up Notepad and type in the following words. Save the file as collectionOfWords.txt...
I need python code for this. Write a program that inputs a text file. The program...
I need python code for this. Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Uppercase words should take precedence over lowercase words. For example, 'Z' comes before 'a'. The input file can contain one or more sentences, or be a multiline list of words. An example input file is shown below: example.txt the quick brown fox jumps over the lazy dog An example of the program's output...
I cannot upload the needed text files to this question for your benefit of double checking...
I cannot upload the needed text files to this question for your benefit of double checking your solution, but I need help on this multi part question. Thanks! Write a Python program that will open the ‘steam.csv’ file. Your program should load the data as col- umns corresponding to the variable names located in the first row (You can hard code this – i.e open the file and use the names in the first row as variable names). You should...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write()...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write() and read() functions with binary                                                        data, where the data is not char type.              (Typecasting is required) Fill in the blanks, then enter the code and run the program. Note:   The data is int type, so typecasting is            required in the write() and read() functions. #include <iostream> #include <fstream> using namespace std; int main() {    const int SIZE = 10;   ...
Writing a program in Python that reads a text file and organizes the words in the...
Writing a program in Python that reads a text file and organizes the words in the file into a list without repeating words and in all lowercase. Here is what I have #This program takes a user input file name and returns each word in a list #and how many different words are in the program. while True:   #While loop to loop program     words = 0     #list1 = ['Programmers','add','an','operating','system','and','set','of','applications','to','the','hardware',          # 'we','end','up','with','a','Personal','Digital','Assistant','that','is','quite','helpful','capable',           #'helping','us','do','many','different','things']        try:        ...
C++ PROGRAM 1. Open the file input called "info.txt" read it and store the data in...
C++ PROGRAM 1. Open the file input called "info.txt" read it and store the data in a vector. 2. Order the data by IP to perform the searches 3. Ask the user for the information search start and end IP's - Example of data on the info text: Jun 11 23:26:10 908.93.383.85:4940 Failed password for admin Aug 2 05:13:39 355.45.117.69:4551 Failed password for root Oct 24 02:32:14 852.37.168.72:6796 Illegal user 4. Display the records corresponding to those IPs 5. Store...
IN MIPS ASSEMBLY Macro File: Create macros to print an int, print a char, print a...
IN MIPS ASSEMBLY Macro File: Create macros to print an int, print a char, print a string, get a string from the user, open file, close file, read file, and allocate heap memory. You can use more macros than these if you like. Main Program File: Allocate 1024 bytes of dynamic memory and save the pointer to the area. The main program is a loop in which you ask the user for a filename. If they enter nothing for the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT