Hello, those are 2 parts of my simple program.
It uses data structure with classes.
I have a loop sending the cars to the class function to check them if are modified(bool value).
I want at the end of the process to display a message like "The cars that are modified are the: ferrari * porsche"
or
If are not modified cars to display "No modified cars"
1 2 3 4 5
void listModified(warehouse ArrayOfStruct[],int numberOfCars)
{
for (i=0;i<numberOfCars;i++)
ArrayOfStruct[i].printModified();
}
1 2 3 4 5 6 7 8 9 10 11
void warehouse::printModified()
{
if (PRVmodified == 1)
{
cout<<"The following cars are modified "<<endl;
cout<<PRVcar<<" * ";
}
else
cout<<"There are not modified cars "<<endl;
}
I tried to addthe modified cars in a message with strcat but didn`t work.
Any ideas ?
Didn't understand what you want. For example if there are 3 cars (I assume that warehouse means one car?) : a modified ferrari, modified porche and unmodified beetle, you want to get
The following cars are modified ferrari * porche
There are not modified cars
right?
And if we swap unmodified beetle with modified porche, do you want the output to be the same?
listMoified{
create a vector of char*.
for each car in array, if modified, push its name into the vector.
for int i from 0 to vecrtor size{
if i > 0, print '*'
print vector[i]
}
if vector size < array size, print "There are not modified cars "
}
It doesn't really have to be a vector. char*[] and int could do the same.