# queue

This topic is 2507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

[attachment=1832:labtask 4- queue.txt]i made a program in C++, the code of a queue, wat happened,,my compiler gave an error that the variable around queue is corrupted,,i found the solution, by adding [ getche(); ] at the end of the code, just before [ return 0; ], and the problem got solved, although getche(); is used to hold the black screen in older compilers like DEV C++ , and i was working on Microsoft Visual Studio 2010, a much advanced compiler.. but even then i was compeeled to add getche(); ,,because my code was making the memory crashed.. and adding getche(); was restricting the memory to get crashed...

##### Share on other sites
You make an array of 15 elements, which means it's valid to use index values from 0 through to 14.
Every single one of your index values is out of bounds. You start at -1, and then decrease from there.int qu[15]; qu[-1] = 1000; cout << "(1): "<<qu[-1] <<endl;
Your calls to [font="'Lucida Console"]put[/font] are overwriting the contents of the stack.