Ask Question

Given the availability of an ofstream object named output, and a string variable name tweet, write the other statements necessary to open a file named "mytweet", display the prompt tweet: and then read an entire line into tweet and then write it out to the file mytweet. (Do not define a main function.)

+2
Answers (1)
  1. 29 May, 05:16
    0
    The answer to this question can be given as:

    code:

    cout << "tweet:"; / /print message.

    getline (cin, tweet); / /calling function getline.

    output. open ("mytweet"); / /calling open by creating object of ofstream.

    output << tweet;

    output. close (); / /close file.

    Explanation:

    In the above c+ + programming language code firstly we print the tweet variable as a message. Then we call the getline () function. In this function, we pass two variables that is cin and tweet. Then we create the object of the ofstream class that is output Then we open a file and call this file by output. In the next line, we use the output as a class function to print the value of the tweet variable. At the last, we close the file.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Given the availability of an ofstream object named output, and a string variable name tweet, write the other statements necessary to open a ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers