This bit of code below is reading in a stringstream and adding each piece to a struct, and once its done its adds the whole struct to a list of structs.board is the temporary struct and then
while (getline(ss, word, ',')){
if (wordIndex==0){
board.item = word;
}
else if (wordIndex==1&&word==" for sale"){
board.forSale = false;
}
else if (wordIndex==1&&word==" wanted"){
board.forSale = true;
}
else if (wordIndex==2){
board.price = atoi(word.c_str());
}
wordIndex++;
}
index ++;
messageBoard.push_back(board);
I also have this function im trying to create that compares the contents of board, with the contents of array. Not sure if I need to compare it with an iterator or just compare the items individually.
bool compare(struct messageBoard* one, struct messageBoard* two){
return(one.item==two.item&&one.forSale!=two.forSale&&one.price<=two.price)
}
Thats as far as I've gotten. The goal is if Item matches and the forSale values are opposites(True vs False) and the price of the for sale is <= to the wanted item, then the bool function returns True, else it returns false. I want to run it right before the
arr.push_back(board);