I'm having some trouble with a few while loops. I've written them, and they worked great originally, however I added code to a different part of my program, and now the loop runs infinitely.
std::stringstream strm;
std::string num;
int u = 0;
u = j;
j += 1;
strm << j;
strm >> num;
inventory[u].invno = num;
When the loop actually worked, I had that part just written as inventory[j].invno = j;
However, in the loops, the inventory[x].invno would not display. Now, I can tell it displays, but the code loops infinitely.
Any ideas why?
You are checking conditions that never will be changed within your loop. Unless some element in inventory doesn't have an empty string, and then gets checked by x, your loops will repeat infinitely.