Mark44
Mentor
- 38,051
- 10,553
The code in post #29 doesn't print anything, so it's possible there's a bug in your routine that prints the contents of the message list.
Your for loop needs some adjustment.
1) Assuming there are n messages in the message list, i ranges from 0 to n - 1. When i == n - 1, you are check message[n-1] and message[n], which is past the end of your list.
2) If you find the right place to add the message, insert the message and then bail out of your loop. I mentioned this back in post #17.
mark44 said:You could put the if statement above inside a for loop, and break out of the loop (with break;) when the if condition is met.