|
-
April 22nd, 2010, 01:02 PM
#1
More help with arrays?
I dont know whats the problem. I followed everything the teacher taught me in class but this code just keep having errors!!! I feel like crying now. I am too lazy to explain the problem now. Its late and i feel sad. I will just post the code and someone please be a kind person and compile it in your dev c++. Please tell me what is the problem. I have to sleep now. Thank you very much in advance.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct weapon
{
string id;
string name;
string quantity;
};
weapon view(weapon add[],int size);
//VIEWING WEAPON
weapon view(weapon add[],int size)
{
cout<<setw(15)<< "Weapon id" <<" "<<setw(15)<<"Weapon_name" <<" " <<setw(15)<< "Weapon Quantity"<< endl;
for(int l=0; l<size;l++)
{
cout<<setw(15)<< add[l].id<<" "<<setw(15)<< add[l].name<<setw(15)<<add[l].quantity<< endl;
}
return add[size];
}
//DELETING FUNCTION
weapon deleting( weapon add[], int size)
{
string weapon_id;
cout<< "Enter the id of teh weapon you wanna delete."<< endl;
cin>> weapon_id;
int b=0;
bool out=true;
//QUERY
for (int a=0; a<size|| out; a++)
{
if (add[a].id==weapon_id)
{
cout<< setw(15)<< add[a].id<< " "<<add[a].name<< " "<<add[a].quantity<< endl;
cout<< "This is teh weapon you wanna delete at row "<< a << endl;
out=false;
}
}
//DELETING DATA
int n=a;
for( n; n<size; n++)
{
add[n]=add[n+1]
}
}
int main()
{
cout<< "First, you gotta insert the records first"<< endl;
int i,k,size,l;
i=1;
l=0;
k=1;
cout<< "Enter size of record"<< endl;
cin>> size;
weapon add[ size];
for( l=0; l<size;l++)
{
cout<<"Enter the id"<< endl;
cin>> add[l].id;
cout<<"Enter the name"<< endl;
cin>> add[l].name;
cout<<"Enter the quantity"<< endl;
cin>> add[l].quantity;
}
char quit;
bool again=true;
while(again)
{int choice;
cout<< "1: By choosing this mindblasting option you have choosen to either delete the record of weapon in the weapon inventory or you are stealing my weapons \n";
cout<< "2: By choosing this fantastic option you just condemned yourself to modify the records of my inventory \n";
cout<< "3: By choosing this crazy option you will have the ability to view my super duper top secret records \n";
cout<< "4: By choosing this sad option you have chosen to leave this place \n" ;
cin>> choice;
switch(choice)
{
case 1: cout<<"1"; break;
case 2:break;
case 3:view( add[size],size); break;
case 4: again=false; break;
}
cout<< "Again? Y/N"<< endl;
cin>> quit;
if (quit=='Y')
again=false;
}
system ("PAUSE");
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|