You are here:

C++/Text File in C++

Advertisement


Question
Respected Sir,

Plz tell me how we can read the data on starting up of any C++ application and how we can store/save data on ending up of the C++ application.

Answer
Hi Muhammad

Try writing it life this.

class MyClass{

private:
char *filaname;

public:
MyClass(){
\\logic to read a particular file and store data
}

void otherMethod(){
\\other methods
}

~MyClass(){
\\logic to save data in a particular file
}
};

void main(){
MyClass mc;
mc.otherMethod();
}

This will call the constructor that will load a particular file and then perform any other methods then when the object will go out of scope the destructor will be called automatically to store the data back again into the file.

regards
Joydeep Bhattacharya
http://www.scodz.com

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Joydeep Bhattacharya

Expertise

TSR, Socket and Very Complex Mathematical Problem

Experience

Worked on many OOP projects with design patterns

Organizations
http://www.scodz.com

Publications
http://www.scodz.com

Education/Credentials
Master of Computer Applications

Awards and Honors
Being a proud owner of a website of programming called http://www.scodz.com

Past/Present Clients
http://www.funforu.com http://www.dhoondho.com http://analysingc.50webs.com

©2016 About.com. All rights reserved.