• Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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...
here's my code..[attachment=1832:labtask 4- queue.txt]

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement