English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

well,i am trying to make a program for a book shop ,
but i am unable to store the information of books permanently.
i.e i have used structure for storing it.but for every new run of the program i have to enter data .I know concept in c++ till classes and objects.suggest some way or give code in c++,to solve this problem.

2006-08-15 16:56:15 · 6 answers · asked by Abhishek 1 in Computers & Internet Programming & Design

6 answers

#include
at the top of your program

Then do:
ofstream file;
file.open("Myfile.dat", ios::create | ios::out);
file << data1 << endl << data2 << endl << data3;
file.close();
Where datan is your piece of data. This produces a simple ASCII file.

2006-08-15 17:02:52 · answer #1 · answered by jacinablackbox 4 · 0 0

Read about file handling first. That would teach you how to write to and read from files.

Or you can prepopulate yor data structures. Write a function that prepoluates your data structure , for example

class Temp { int x; int y; }
Temp tdata[10]

void addData()
{
tdata[0].x = 1; tdata[0].y=14;
tdata[1].x = 7; tdata[1].y = 199;
...
}
and call the function when u need the data.

But in the long run, read File Handling.
Also you can use databases like mysql (which is free).

2006-08-15 22:10:58 · answer #2 · answered by Amrendra 3 · 0 0

Classes and Object is the fundamental knowledge in C++ To do such a thing like permanent data storing you have to know the file accessing in C++. That’s why you have to use the fstream.h header file. Refer to the source link for more details about the file accessing with C++

2006-08-15 17:21:31 · answer #3 · answered by Nishan Saliya 4 · 0 0

Do no format USB drives with domicile windows. Use HP formatting gadget or comparable classes and format in Fat32. attempt thechronic in powered USB port at backside of the computing gadget. Wait till each and every situation is written to thechronic till now ejecting it. stable success with your chinese language products.

2016-11-04 21:58:38 · answer #4 · answered by ? 4 · 0 0

It might be worth your while to install a database and us a C++ library to access it. It's a bit of a learning curve, but nothing too serious.

http://www.sqlapi.com/ for example
Databses are free these days (mysql and others).

2006-08-15 17:29:36 · answer #5 · answered by sheeple_rancher 5 · 0 0

Use open source DB's like mySql or postGre.

2006-08-15 18:20:59 · answer #6 · answered by rohitn23 s 1 · 0 0

fedest.com, questions and answers