The problem is that i dont know where to put the array to keep inventory expanding...someone please help.

#include <iostream.h>
#include <lvp\string.h>
#include  <lvp\vector.h>

struct rec{

	long sku;
	String artist;
	String album;
	long quantity;
	double price;
};//end struct

struct inv{
	inv();//constructer
	vector<rec>album;
};

inv::inv()
:album(0)

{}

/////////////////////////////////////////////////////////////////	
void read(rec&rec);//reads in records at start
void printer(rec&rec);//prints records
void add(rec&rec);//adds records to inventory
void del(rec&rec);//deleted records in inventory
void sell(rec&rec);//sells available inventory

int main(){
	rec rec;
	inv inv;
	char answer;//answer for adding a new record at start
	int menu_answer;//answer for menu
	cout<<"\t\t\tThis Register Open"<<endl<<endl;
	do{	
		cout<<"Would you like to add a new record to inventory(y/n)? ";
		cin>>answer;
		if((answer=='y'||answer=='Y')){
			read(rec);
		}//end if
		else{
			break;
		}//end else

		
		

	}while((answer!='N')||(answer!='n'));
	system("cls");

	
	do{
	cout<<"Dj Mega Emporium"<<endl;
	cout<<"\tMain Menu"<<endl<<endl;
	cout<<"1)\tSell a record."<<endl;
	cout<<"2)\tAdd a record."<<endl;
	cout<<"3)\tDelete a record."<<endl;
	cout<<"4)\tPrint record inventory report."<<endl;
	cout<<"5)\tExit"<<endl<<endl;
	cin>>menu_answer;
	system("cls");
	

	if(menu_answer==4){
		printer(rec);
		cout<<endl;
	}//end if

	else if(menu_answer==2){
		add(rec);
		cout<<endl;
	}//end else if

	else if(menu_answer==3){
		del(rec);
		cout<<endl;
	}//end else if
	
	else if(menu_answer==1){
		sell(rec);
		cout<<endl;
	}//end else if
	else if(menu_answer==5){
		cout<<"k bye"<<endl;return 0;
	}//end else if
	else{
		cout<<"Please choose a correct option"<<endl<<endl;
	}//end else

	}while(menu_answer!=5);//end do while
	system("cls");
	cout<<"k bye dont come back"<<endl;
	return 0;
	
}//end main

void read(rec&rec){//reads in record data
	cout<<"Enter the Sku Number: ";
	cin>>rec.sku;
	cout<<"Enter the Artist: ";
	cin>>rec.artist;
	cin.ignore(100, '\n');
	cout<<"Enter the Album: ";
	getline(cin,rec.album);
	cout<<"Enter the Quantity: ";
	cin>>rec.quantity;
	cout<<"Enter the price: ";
	cin>>rec.price;
	cout<<endl<<endl;
	cout<<"Record Added to Inventory"<<endl<<endl;
	

	return;
}//ends function

void printer(rec&rec){


	cout<<"Sku #: "<<rec.sku<<endl;
	cout<<"Artist: "<<rec.artist<<endl;
	cout<<"Album: "<<rec.album<<endl;
	cout<<"Quantity: "<<rec.quantity<<endl;
	cout<<"Price: "<<rec.price<<endl;
	return;
}//ends function

void add(rec&rec){
	int adding;
	cout<<"Please enter the sku number of the record you are adding ";
	cin>>rec.sku;
	cout<<endl;
	cout<<"We already have "<<rec.quantity<<" copies of "<<rec.artist<<"-"<<rec.album<<" in our inventory"<<endl;
	cout<<"How many would you like to add? ";
	cin>>adding;
	rec.quantity=rec.quantity+adding;
}//ends function

void del(rec&rec){
	cout<<"Enter the sku number of the record to delete :";
	cin>>rec.sku;
	cout<<rec.artist<<"-"<<rec.album<<" has been deleted";

}	//ends function

void sell (rec&rec){
	int purchasing;
	do{
	cout<<"Please enter the sku number of the record you are buying: "<<endl;
	cin>>rec.sku;
	cout<<endl;
	cout<<"Please enter how many books you wish to purchase: "<<endl;
	cin>>purchasing;
	if(purchasing>rec.quantity){
		cout<<"Please choose a smaller amount"<<endl<<endl;
	}//end if
	}while(purchasing>rec.quantity);//end do while
	rec.quantity=rec.quantity-purchasing;
}//ends function
Member Avatar for iamthwee

First of all look at your compiler warnings... and fix them.

#include <iostream.h>
#include <lvp\string.h>
#include  <lvp\vector.h>

struct rec
{

   long sku;
   String artist;
   String album;
   long quantity;
   double price;
}
;//end struct

struct inv
{
   inv();//constructer
   vector<rec>album;
};

inv::inv(): album ( 0 )

{}

/////////////////////////////////////////////////////////////////
void read ( rec&rec );//reads in records at start
void printer ( rec&rec );//prints records
void add ( rec&rec );//adds records to inventory
void del ( rec&rec );//deleted records in inventory
void sell ( rec&rec );//sells available inventory

int main()
{
   rec rec;
   inv inv;
   char answer;//answer for adding a new record at start
   int menu_answer;//answer for menu
   cout << "\t\t\tThis Register Open" << endl << endl;
   do
   {
      cout << "Would you like to add a new record to inventory(y/n)? ";
      cin >> answer;
      if ( ( answer == 'y' || answer == 'Y' ) )
      {
         read ( rec );
      }//end if
      else
      {
         break;
      }//end else

   }
   while ( ( answer != 'N' ) || ( answer != 'n' ) );
   system ( "cls" );


   do
   {
      cout << "Dj Mega Emporium" << endl;
      cout << "\tMain Menu" << endl << endl;
      cout << "1)\tSell a record." << endl;
      cout << "2)\tAdd a record." << endl;
      cout << "3)\tDelete a record." << endl;
      cout << "4)\tPrint record inventory report." << endl;
      cout << "5)\tExit" << endl << endl;
      cin >> menu_answer;
      system ( "cls" );


      if ( menu_answer == 4 )
      {
         printer ( rec );
         cout << endl;
      }//end if

      else if ( menu_answer == 2 )
      {
         add ( rec );
         cout << endl;
      }//end else if

      else if ( menu_answer == 3 )
      {
         del ( rec );
         cout << endl;
      }//end else if

      else if ( menu_answer == 1 )
      {
         sell ( rec );
         cout << endl;
      }//end else if
      else if ( menu_answer == 5 )
      {
         cout << "k bye" << endl;
         return 0;
      }//end else if
      else
      {
         cout << "Please choose a correct option" << endl << endl;
      }//end else

   }
   while ( menu_answer != 5 );//end do while
   system ( "cls" );
   cout << "k bye dont come back" << endl;
   return 0;

}//end main

void read ( rec&rec )
{//reads in record data
   cout << "Enter the Sku Number: ";
   cin >> rec.sku;
   cout << "Enter the Artist: ";
   cin >> rec.artist;
   cin.ignore ( 100, '\n' );
   cout << "Enter the Album: ";
   getline ( cin, rec.album );
   cout << "Enter the Quantity: ";
   cin >> rec.quantity;
   cout << "Enter the price: ";
   cin >> rec.price;
   cout << endl << endl;
   cout << "Record Added to Inventory" << endl << endl;


   return;
}//ends function

void printer ( rec&rec )
{


   cout << "Sku #: " << rec.sku << endl;
   cout << "Artist: " << rec.artist << endl;
   cout << "Album: " << rec.album << endl;
   cout << "Quantity: " << rec.quantity << endl;
   cout << "Price: " << rec.price << endl;
   return;
}//ends function

void add ( rec&rec )
{
   int adding;
   cout << "Please enter the sku number of the record you are adding ";
   cin >> rec.sku;
   cout << endl;
   cout << "We already have " << rec.quantity << " copies of " << rec.artist << "-" << rec.album << " in our inventory" << endl;
   cout << "How many would you like to add? ";
   cin >> adding;
   rec.quantity = rec.quantity + adding;
}//ends function

void del ( rec&rec )
{
   cout << "Enter the sku number of the record to delete :";
   cin >> rec.sku;
   cout << rec.artist << "-" << rec.album << " has been deleted";

}	//ends function

void sell ( rec&rec )
{
   int purchasing;
   do
   {
      cout << "Please enter the sku number of the record you are buying: " << endl;
      cin >> rec.sku;
      cout << endl;
      cout << "Please enter how many books you wish to purchase: " << endl;
      cin >> purchasing;
      if ( purchasing > rec.quantity )
      {
         cout << "Please choose a smaller amount" << endl << endl;
      }//end if
   }
   while ( purchasing > rec.quantity );//end do while
   rec.quantity = rec.quantity - purchasing;
}//ends function

Compile log

thwee@thwee-desktop:~$ g++ -Wall pedantic.cc
In file included from /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward/iostream.h:31,
                 from pedantic.cc:1:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
pedantic.cc:2:24: error: lvp\string.h: No such file or directory
pedantic.cc:3:25: error: lvp\vector.h: No such file or directory
pedantic.cc:9: error: ‘String’ does not name a type
pedantic.cc:10: error: ‘String’ does not name a type
pedantic.cc:19: error: ISO C++ forbids declaration of ‘vector’ with no type
pedantic.cc:19: error: expected ‘;’ before ‘<’ token
pedantic.cc: In constructor ‘inv::inv()’:
pedantic.cc:22: error: class ‘inv’ does not have any field named ‘album’
pedantic.cc: In function ‘void read(rec&)’:
pedantic.cc:117: error: ‘struct rec’ has no member named ‘artist’
pedantic.cc:120: error: ‘struct rec’ has no member named ‘album’
pedantic.cc: In function ‘void printer(rec&)’:
pedantic.cc:137: error: ‘struct rec’ has no member named ‘artist’
pedantic.cc:138: error: ‘struct rec’ has no member named ‘album’
pedantic.cc: In function ‘void add(rec&)’:
pedantic.cc:150: error: ‘struct rec’ has no member named ‘artist’
pedantic.cc:150: error: ‘struct rec’ has no member named ‘album’
pedantic.cc: In function ‘void del(rec&)’:
pedantic.cc:160: error: ‘struct rec’ has no member named ‘artist’
pedantic.cc:160: error: ‘struct rec’ has no member named ‘album’

idk if ur a noob or what becuz libraries are different everywhere

Member Avatar for iamthwee

No there is no excuse to write c++ in the manner you have written. And you are asking a daft question because what makes you think we've got your libraries?

Member Avatar for iamthwee

And more to the point, if you had used standard libraries, you could have used methods available from the std::vector, such as push_back() and erase() to complete your task.

:-/

aright 1st of all im in computer programming one, so i wouldnt be able to use that style nor use the libraries you just mentioned. I have to use the supplied libraries from the school...and ur not helping so stop posting spam like this.:D

Member Avatar for iamthwee

Well ask your little school what methods you can use in your little classes instead of wasting my time. :D

If you have a brain you will realise that:-

void del ( rec&rec )
{
   cout << "Enter the sku number of the record to delete :";
   cin >> rec.sku;
   cout << rec.artist << "-" << rec.album << " has been deleted";

}	//ends function

(amongst your many other faults)
achieves nothing. :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.