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
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...
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.
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.
Describe how signal and signal management calls are used in creating a process and terminating it...
Describe how signal and signal management calls are used in creating a process and terminating it after certain interval. Give a simple example to illustrate this routine.
Why is the consumer shopping and purchasing model presenter within the text called a process model?...
Why is the consumer shopping and purchasing model presenter within the text called a process model? Explain how understanding this process could affect retailers actions:
(a) Does the Texthide program change the size of the image? (b) How much text can...
(a) Does the Texthide program change the size of the image? (b) How much text can you store in the image? (c) Does the image with the hidden text look different from the original image? (d) Does Texthide only work on bitmap images?