Jump to content
xisto Community
rize619

University Assignment Help database aplication in c++

Recommended Posts

hey today we have completed our c++ course and over teacher gave us the assignment to make a simplest database aplication that can permanentaly store and retrieve the data about anything it may be student data , students marks data any hting elsefirstly i want to tell u peoples what things we have learned so faar1. LOOPS2. Function3. Pointers4. file handlingwe have learned clases arrays etcso plese help me with very simplest database aplication in C++. i have searched many websites but could not find any database aplication as i just like ... plz share with me some source codes ,,,,,,,, but remember for very begineers ...thanks alot..

Share this post


Link to post
Share on other sites

well, if we just gave you the source code that would be cheating wouldn't it? :) I think a better way to be asking us for help on your university assignment would be to write up some code and ask us for any suggestions on some problems you may have. As for the structure of the program, i can't really help you, especially right now (it's 5:30 AM and i'm not a morning person), I've never taken a class so i've never learned to document my work; therefore, i never do :) . Anyways, write up some stuff for your assignmen and post it here, i'd be glad to help you in the actual programming of it, i've been doing C++ for 5 years now.

Share this post


Link to post
Share on other sites

i think this is a bit offensive since this is your assignment. like what t3jem said, we could give you advises but we can't give you the code for your assignment. the reason why assignments are given is for you to train yourself in programming. you yourself mentioned that you have learned these stuff, so for you to ask us some code, means you haven't learned anything at all. it takes practice even if you're not really good.

Share this post


Link to post
Share on other sites

i know that it is a cheating and there are tonz of source codes avaiable in source codes websites and i am not asking you people to give me the source code and i have my works within 10 minutes the problem is that honestly i am very baad in programming my group leader is already making the assignment as this is the group assignment and now i have told him abt my bad programming practice....plese atleat you peoples give me the step of wich i can understand how this program is going to actually be made...... because i have no concept of it at all..i am only good upto do - while loopplease help me out atleast tell me the steps..

Share this post


Link to post
Share on other sites

Well, the way i think when I write a program to figure out the steps is to figure out how the program should look like on the client side. Start with what the program should do when it is first opened. It should ask the client what to do, right? Well, now that you know what the program should do, you think of how to make the program do it. So you make the program start by prompting the user to ask them what to do. After that, you would execute a function that does what the user wants, right? So, you code the function that would do what it is needed. Since the program would probably have to loop, you do the loop around what you need.Basically, just think about how the program should run, then think how to make the program run how it should. Hope this helps :) .P.S. Though spelling isn't a big deal in these forums, exesive mispelling makes it hard to read your posts, please type slower or more carefully :)

Share this post


Link to post
Share on other sites

first of all sory for my poor as i am not english.. any how here is a code

#include <fstream>#include <string>#include <iostream>#include <stdlib.h>using namespace std;int main()	{		int start; 		string str1 = "___________________________________________\n|||ADDRESS BOOK|||\n___________________________________________\n\n\n\n\n";		string str2;		string str3;		string str4;		string str5;		string str6;		string str7;		string str8;	intro:		cout << "Hello! if this is your first time using Address Book, please enter 1.\n Otherwise press 2." << endl;		cin >> start;		{ 			if(start==1)				{					ofstream myFile("addressbook.txt");						{							if (! myFile)								{									cout << "Error opening output file" << endl;									return -1;								}							}							myFile << str1 << endl;							myFile.close();							system("cls");							cout << "A file under the name 'addressbook.txt' has been created." << endl;								system("pause");								system("cls");						}						else if(start==2)							{								system("cls");								system("pause");								goto menu;							}							else if(start>2||start<1)								{									system("cls");								cout << " NUMBER MUST BE LESS THAN 2 and above 1\a\a\a\a\a" << endl;								system("pause");								system("cls");								goto intro;								}							}						menu:								system("cls");								cout << " 1) Add Entry to address book" << endl;								cout << " 2) View address book(unoperational)" << endl;								cin >> start;									{										if (start==1)											{												cout << "Enter First Name\n" << endl;												cin >> str2;												cout << "Enter Last Name\n" << endl;												cin >> str3;												cout << "Enter Street Number\n" << endl;												cin >> str4;												cout << "Enter Street Name(no spaces in between name and suffix, e.g. CollinsDrive)\n" << endl;												cin >> str5;												cout << "Enter town\n" << endl;												cin >> str6;												cout << "Enter e-mail address\n" << endl;												cin >> str7;												cout << "Enter Phone Number(no spaces)\n" << endl;												cin >> str8;												ofstream myFile("addressbook.txt", ios::app);												myFile << "\t" << str2 << " " << str3 << " " << str4 << " " << str5 << " " << " " << str6 << " " << str7 << " " << str8 << endl;												myFile.close();											}											else if(start==2)												{													system("cls");													ofstream myFile("addressbook.txt", ios::in|ios::in|ios.trunc);												}											}											return 0;								}

I want to ask some thing please explain them one by one..
1.why we use string here instead of char or int
2.Re write the program for me by using switch statement for different fuction performing
3.what is this intro:
4. return -1 will do what ?
5. explain ofstream fuction orignal syntax as well

Thanks a lot if u let explain these thing for me.... but please dont forget to rewrite the source code using switch keyword....

Share this post


Link to post
Share on other sites

I'll try to answer your numbered questions. As for explaining the whole program, i'm a little tired to do that (sorry).

1. A string is basically a char *, except that to you manipulate strings differently (I personally prefer char). Strings will work just as well as char, you just have to manipulate them differently.

2. A switch statement is basically an if statement, an example follows:

switch(variable){case 1://do somethingbreak;case 2://do something elsebreak;}
This is the same as the following code.
if(variable == 1)//do somethingif(variable == 2)//do something
case functions are good if you have a variable that can be of many values that you want to check for, so instead of having 500 if statements, you have one switch statement and 500 cases.

3.the "intro:" is used for a goto statement, instead of using a while loop they create an artificial loop by calling "goto inro;" to go to the begining.

4. The return statement basically returns a value, it is mainly used for debugging, I didn't see the line returning -1, but I would guess it means an error occured (for this particular program, you may have different values in your own).

5. ofstream is a class to specify a file pointer. It is used to create a file pointer so you may output data to a file, ifstream is for reading and fstream is for both.

I hope this helps you understand this code.

Share this post


Link to post
Share on other sites

thannk you surely i understand all the program..
but i can't understand answer to question no 3 ... i am asking here in this code .... when we return -1 then what will the program do it do what with -1 , -1 means what ??

if (! myFile)								{									cout << "Error opening output file" << endl;									return -1;								}
Return -1 will telll what ?
and also please tell me ofstream , fstream etc statement and examples programs..
Edited by rize619 (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.