Question

Explain the process of creating flat (text) files and how to store/retrieve data in c++

  1. Explain the process of creating flat (text) files and how to store/retrieve data in c++

Homework Answers

Answer #1

To create a file in c++ and write data to it it can be done as follows

#include <fstream>

#include <iostream>

#include<string>

using namespace std;

int main()

{

ofstream fout;

//Creating the file sample.txt

fout.open("sample.txt");

if(fout.is_open())

{

//writing content to the file

fout<<"Hello Good Day";

}

//Reading from the file

ifstream fin;

fin.open("sample.txt");

if(fin.is_open())

{

string line;

//reading from the file

while(getline(fin,line))

{

cout<<line;

}

}

return 0;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
briefly explain the process to retrieve the slump. beginning with setting up the slump equipment
briefly explain the process to retrieve the slump. beginning with setting up the slump equipment
How do users retrieve data stored in a database? Select one: a. by viewing the appropriate...
How do users retrieve data stored in a database? Select one: a. by viewing the appropriate data tables b. by executing a query c. by performing a search d. by specifying the primary keys
Explain how to extract steganographic sequestered data from an identified image files while conserving their integrity.
Explain how to extract steganographic sequestered data from an identified image files while conserving their integrity.
1.      Create 100 text files automatically; in each file write a random number from 1 to 10....
1.      Create 100 text files automatically; in each file write a random number from 1 to 10. Use outputstreams (fileoutputstream, buffredwriter….) 2.      Read the content of the 100 files and combine them into a 1 single file. 3.      Write java code to do the following: a.      To write the following text into a text file EEEESAAA@23SDCFSAWERF%WASDFGHWERTRQW b.      Read the file using a java program c.      Find how many D’s in the file d.      Extract the text between the @ and the # 1. Create 100 text files...
How would you go about creating a subroutine in MARIE assembly language that inputs text from...
How would you go about creating a subroutine in MARIE assembly language that inputs text from a keyboard?
C programing language pretend parent process is reading data and child process is writing data. explain...
C programing language pretend parent process is reading data and child process is writing data. explain with pipe and fork function.
C# Reading from Files Write a program to open a text file containing information about buildings....
C# Reading from Files Write a program to open a text file containing information about buildings. The program must display all the buildings in the file and then find the lowest cost building based on the cost per square foot. Format for one building: <building name> <size> sqft $<cost> Example: Allgood Hall 35000 sqft $8,250,099.75 Create the text file and add three or more of your favorite buildings.
C# Reading from Files Write a program to open a text file containing information about buildings....
C# Reading from Files Write a program to open a text file containing information about buildings. The program must display all the buildings in the file and then find the lowest cost building based on the cost per square foot. Format for one building: <building name> <size> sqft $<cost> Example: Allgood Hall 35000 sqft $8,250,099.75 Create the text file and add three or more of your favorite buildings.
explain the process of designing the ETL.(extract transform load) Also explain the Designing of Staging areas...
explain the process of designing the ETL.(extract transform load) Also explain the Designing of Staging areas and creating of mapping. Also discuss in details Transformations in particular: STORE mapping, PRODUCT Mapping, and SALES cube mapping. and discuss the Features and Benefits of OWB.
explain the process of designing the ETL.(extract transform load) Also explain the Designing of Staging areas...
explain the process of designing the ETL.(extract transform load) Also explain the Designing of Staging areas and creating of mapping. Also discuss in details Transformations in particular: STORE mapping, PRODUCT Mapping, and SALES cube mapping. and discuss the Features and Benefits of OWB.