queue

Started by
0 comments, last by Hodgman 13 years ago
[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]

---
[size="2"]huma..

BS-Electronics Engineering,
International Islamic University,
Islamabad, Pakistan
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.

This topic is closed to new replies.

Advertisement