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
The expression that is tested by a switch statement must have a(n) __________ value.
Hitman42 [59]

The answer is relational.

6 0
3 years ago
A customer dictates instruction on how to transcribe audio. Do you have to transcribe the instruction word for word?
Ostrovityanka [42]

Answer:

No

Explanation:

4 0
2 years ago
how do i turn off itallics on a school chromebook i accidentally turned them on in another tab and i dont know how to undo them
Rudiy27
U go in to the bar with i b u the is italics and u press it again and it will turn it off but u have to have the text selected
5 0
3 years ago
To prevent rust from forming, a light coating of_____should be applied to all machined surfaces
Fantom [35]
What is that I never heard of that before
4 0
3 years ago
PLZ HELP ME! <br> Write pseudocode for getting a bowl of ice cream using at least four steps.
inessss [21]
1. Get the material that you need
2. Open the ice cream
3. Scoop out the ice cream using your materials
4. Put that scoop in a bowl
4 0
3 years ago
Other questions:
  • given the numerical value 1010101.11, which of the following number systems is most likely represented.
    11·1 answer
  • Below is a chart representing portions of resumes from 3 applicants. Which best explains the applicants careers?
    11·1 answer
  • When forced distribution is used to reduce leniency bias, this can cause __________ if a pfp system is in place?
    10·1 answer
  • Mention<br>any<br>5<br>indicators of<br>happiness​
    11·2 answers
  • Which email client feature allows you to store the names and information of people you contact frequently?
    5·1 answer
  • User can use ______ commands to search for and correct words in a document
    13·1 answer
  • Identify the benefit of modeling to communicate a solution.
    10·1 answer
  • It connects computers in different cities and different countries
    9·2 answers
  • Write a Java program that has a static method named range that takes an array of integers as a parameter and returns the range o
    10·1 answer
  • What term is commonly used to refer to HTML formatting?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!