Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ ., Write a program to open a text file named CSC2134.TXT for output, then accept lines of text from the console and write

Using C++ ., Write a program to open a text file named "CSC2134.TXT" for output, then accept lines of text from the console and write the lines of text to the file. An empty string can be used to cause the program to quit accepting lines of text from the console and close the file. To test for an empty string (which occurs when you press the Enter key without typing any text), use the strlen() function from the string.h include file. This function will return an integer value indicating the number of characters in a string. Here is an example program to show you how strlen() works: #include #include using namespace std; int main() { char str[] = { "123456789012345" }; cout << strlen(str) << endl; return 0; } You will find a submethod of cin useful. Here is an example: cout << "enter some text:"; cin.getline(str, 80); // str is returned when the enter key is pressed Here is an example of how the input should be done: Enter text: Now is the time Enter text: for all good men Enter text: to come to the aid Enter text: of their party. Enter text: (Enter key pressed)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

What are the key characteristics of Handelsbankens approach?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago