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.)
LANGUAGE: C++
CHALLENGE:
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.)
SOLUTION:
cout << "tweet:"; getline(cin,tweet); output.open("mytweet"); output << tweet; output.close();