Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a function that receives a phone number, a name, an email, and an ostream object and writes a single, formatted line to the

C++

Write a function that receives a phone number, a name, an email, and an ostream object and writes a single, formatted line to the ostream object. The ostream object is where you want the data to be written to.

Using ostream for the last parameter allows you to send cout or an ofstream object. This makes it easy to test this function with cout before you try it with a file. The ostream object must be passed by reference.

The format of the output is very specific. Use setw to make sure everything fits as expected on the line. Each line is to contain the following.

  • a phone number
    • lines up on the right
    • uses 16 spaces
  • two blank spaces
  • a name
    • lines up on the left
    • uses 19 spaces
    • when a name is longer than 19 characters, print the first 16 characters of the name followed by three dots (...).
  • two blank spaces
  • an email
    • lines up on the left
  • a carriage return (\ or endl)

Add the function prototype in the directories.h file.

 void WriteFormatted(std::string phone, std::string name, std::string email, std::ostream& out); 

Write the function definition in the directories.cpp file.

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

Step: 3

blur-text-image

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago