search back statement in arrays

Hi i need an answer here if anyone know pls tell me.

I have an arrays that had 50 statement. So now may problem is when i want to alter or change once of the statement that i already wrote out, which coding will i need to use?

I know how to change the whole statement information but if i want to find only the particular statement and change it which coding should i need?

IF anyone know about it pls give me a guide.....

THK here first for anyone that help me !!!!!!!!!
Last edited on
What do you mean by "statement"? Do you mean an element of the array?

1
2
3
int myArray[50];   //this is an array of integers with 50 elements.
myArray[23] = 100;   //the 23rd element of the array now has a value of 100.
std::cout << myarray[23];   //outputs the value of the 23rd element of the array 
Last edited on
Hmm...maybe i not in detail form...
Now i will paste down my coding and hope you all can help me ...

#include <iostream>
#include <cstring>
using namespace std;
struct totalSales
{
char name[50];
float price;
int copy_a;
int copy_s;
float sales;

};
void change (totalSales &);
int main ()
{
totalSales t1[50];
int a,b;
float total=0;
char ch;


for (a=0;a<50;a++)
{
cout<<"Enter the book title:"<<endl;
cin.getline (t1[a].name,50,'\n');
cout<<"Price for the book:"<<endl;
cin>>t1[a].price;
cout<<"The copy available:"<<endl;
cin>>t1[a].copy_a;
cout<<"The copy that sale:"<<endl;
cin>>t1[a].copy_s;
t1[a].sales=t1[a].price*t1[a].copy_s;
total=total+t1[a].sales;
cin.ignore ();
cout<<endl;
}
cout<<"Do you need any changing?(y/n)"<<endl;
cin>>ch;
while (ch == 'y' || ch == 'Y')
{
for (a=0;a<50;a++)
{
change (t1[a]);
}
cout<<"Do you need any changing?(y/n)"<<endl;
cin>>ch;
}

cout<<endl<<endl<<"The information for the books are as
follow:"<<endl<<endl;
for (b=0;b<50;b++)
{
cout<<"Title:"<<t1[b].name<<endl;
cout<<"The price of the book:"<<t1[b].price<<endl;
cout<<"Copy available:"<<t1[b].copy_a<<endl;
cout<<"Copy already sold:"<<t1[b].copy_s<<endl;
cout<<"Total sales for the book is:"<<t1[b].sales<<endl<<endl<<endl;
}
cout<<"The total daily sales is :"<<total<<endl;
return 0;
}
void change ( totalSales &m)
{
int a;
float price;
char text[50];
int copy_a,copy_s;

for (a=0;a<1;a++)
{
cin.ignore ();
cout<<endl<<"New title:"<<endl;
cin.getline (text,50);
cout<<"New Price:"<<endl;
cin>>price;
cout<<"Copy available:"<<endl;
cin>>copy_a;
cout<<"Copy sales:"<<endl;
cin>>copy_s;

cout<<endl;

strcpy(m.name,text);
m.price=price;
m.copy_a=copy_a;
m.copy_s=copy_s;
}
}

The coding above show that i had a 50 statement in an arrays.

I know how to change the whole 50 information in once at the same time,but if i wan to change only the particular statement from the 50 statement.

How can i do that.......pls give me a guide

THK for anyone that help me!!!!!
Last edited on
Topic archived. No new replies allowed.