Issue with function

1
2
3
4
5
6
7
8
9
void add_inventory(string item){

int x; //Counter
	while (x << bag_space){ //While counter is lower than bagspace
		if (inventory[x] == "Empty") {inventory[x] = item;} //Free spot.
		if (inventory[x] != "Empty") {x++;} //Spot not empty, keep going.
	}
	if (x >> bag_space) {cout << "Inventory is full!" << endl;} //Full
}


Hmmm. This code doesn't give me a compiler error, it just does nothing at all. Can anyone explain this to me? I don't see why this isn't working.

For example, using it like add_inventory("Sword");
<< and >> are bit shift operators, not comparisons.

Alright that makes sense. I read somewhere about using inventory[x].compare
Topic archived. No new replies allowed.