1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ad libitum [116K]
3 years ago
6

Read first a user's given name followed by the user's age from standard input. Then use an ofstream object named outdata to writ

e this information separated by a space into a file called outdata. Assume that this is the extent of the output that this program will do. Declare any variables that you need.
Computers and Technology
1 answer:
Stells [14]3 years ago
8 0

Answer:

/*

* Program to write data to text file.

*/

#include<iostream>

#include<fstream>

#include<string.h>

using  namespace std;

int main()

{

//Variable to name and age of a person.

string name;

int age;

cout<<"Enter your name"<<endl;

cin>>name;

cout<<"Enter your age"<<endl;

cin>>age;

     //Creating object of ofstream.

   ofstream file;

   file.open ("outdata.txt");

   //Writing data to file named outdata.txt

   file<<name<<" "<<age;

   file.close();

 

}

Output:

Enter your name

John

Enter your age

25

Content of Output.txt:

John 25

Explanation:

To write data to a file  ofstream object is used. An ofstream object file is created first and then using this object a file named "outdata.txt" is created.

Finally using shift operator (<<), by means  of operator overloading, name and age of  person is transferred to file outdata.txt.

You might be interested in
What can detect 8 colors?
Semmy [17]
The color sensor if i’m correct
8 0
3 years ago
Read 2 more answers
I want to do is speed test to do i go to for my computer
laiz [17]

I just go to the speed test on my browser

7 0
3 years ago
you have obtained a program under development to test on your computer. While you are using the program, it crashes with a messa
LenKa [72]

Answer:

It leaves behind Error Code 5

Explanation:

This happens when the parameter provided fails the function requirement this could be as a result of wrong data type or when the parameter provided exceeds the function requirement.

5 0
3 years ago
Define application software​
sp2606 [1]

Answer: An application software is a type of software that the user interacts with, while a system software is a type of software that the system interacts with.

Hope this helped you :)

7 0
3 years ago
Identify the subject: Computer graphics are amazing these days.
Shtirlitz [24]
B.................................
3 0
4 years ago
Read 2 more answers
Other questions:
  • When activating windows, which type of volume activation is used to activate multiple windows systems, but must be individually
    12·1 answer
  • Who invented autonomous cars? When I look it up it comes up as William Bertelsen but he invented the idea of hovering cars. Help
    8·1 answer
  • ____ is a font that resembles the letters that typewriters produced.
    9·1 answer
  • What does network administration normally include? Check all of the boxes that apply.
    8·1 answer
  • Write a C program that reads two hexadecimal values from the keyboard and then stores the two values into two variables of type
    15·1 answer
  • Which sentence indicates that Jeff is mentioning the visual synopsis in his proposal while planning a media project?
    10·1 answer
  • In this assignment, you will implement an online banking system. Users can sign-up with the system, log in to the system, change
    14·1 answer
  • MSWord is a popular___________ program.​
    7·2 answers
  • Which of these would be the best way to inform an employee that they are losing their job?
    13·1 answer
  • What would a good digital citizen do if he sees his classmate left her email account open on a school computer by mistake?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!