Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to use c++ to create database

How to use c++ to create database

How to use c++ to create database

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

This depends on what version of C/C++ you are using.  If you are using Microsoft Visual C++, you can go to the MSDN site to find out how to link to Excel, Access, etc.
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

RE: How to use c++ to create database

hi steve
 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

Hello again!  You will have to save your data in order to
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.
   fprintf(fp, "%d\t",p->first);
   fprintf(fp, "%d\t",p->second);
   fprintf(fp, "%d\n",p->third);
//Now, close the file to observe the niceties

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.


RE: How to use c++ to create database

hi! Steve
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


RE: How to use c++ to create database

HI steve..
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,,


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close