How to use c++ to create database
How to use c++ to create database
(OP)
Hi!
Can any one help me out to create a database using a c++ programs.I want to keep a record of all my employees,so in that case how to do it .
Can any one help me out to create a database using a c++ programs.I want to keep a record of all my employees,so in that case how to do it .





RE: How to use c++ to create database
If you are using C (not C++) you will want to use a linked list for your database. You create a structure whose members become the information you want to keep. Then declare pointers to the structure to allow you to traverse the list and keep the info in order. I don't have any code around for this type of database any more but you can find such a linked list in many places on the internet.
Try programmersheaven.com first since they have lots of code in nicely structured groups.
Good luck
Steve
RE: How to use c++ to create database
Thanks for your suggestions for my query.
steve you have suggested me to have a structured linked list to have a data base.
steve i have tryed out linked list with c & c++. But the
problem that i am facing is that when i create a linked list and add all my data it works fine .But the problem is that when i closed my linked list program and then again try to open the same programm and want to gather the information which i have added then i am unable to get it.
which means that the data remains till the programm is running.
so, there must be some solution for that.so if u could help in that case i would be very much helpfull for that.
bye steve
thanks once again.
RE: How to use c++ to create database
retrieve it again. There are some neater file write/read methods available these days but no matter what compiler you are using, you can always fall back on the old (C) style of formatted i/o. These will work (as far as I can tell) with anything.
To begin with, you need to declare a pointer to a file. Files are structures in the old-style C syntax. This will look something like this:
FILE *fp; // Declare a pointer to a file structure
fp = fopen("junk.dat", "w+"); // This opens a file called
//junk.dat for writing (and reading).
//Now you want to write to the file - let's assume you have
//a data structure called Junk with three int members and a
//counter called cnt.
//Assuming that *p is a pointer to the structure.
while(i<=cnt)
{
fprintf(fp, "%d\t",p->first);
fprintf(fp, "%d\t",p->second);
fprintf(fp, "%d\n",p->third);
i++;
}
//Now, close the file to observe the niceties
fclose(fp);
You can open the file again at any time and run thru a loop
looking for EOF. Same sort of thing as before:
fp = fopen("junk.dat", "r+"); //Open for reading +.
Use fscanf if you are sure your data will
always be properly formatted (by type). Otherwise you can use fgets and convert using atoi() or some such.
I hope this is of some help.
Steve
RE: How to use c++ to create database
Thanks again for your Suggestions!
Steve as u have said to use file handling to create a database i will do so.I have copied your code & with necessary changes i will try it out.
I will inform u about that.
thanks again
regards
feroz
RE: How to use c++ to create database
came back to this forum after years...
saw ur replies..
nice to see someone replied to my queries..
well at this moment i have totally forgotten programming.. reason being not in touch,,
anyways..
byee