Sign in to follow this  
huma.shaheen7@gmail.com

queue

Recommended Posts

[size="2"][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]

Share this post


Link to post
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.[code]int qu[15];
qu[-1] = 1000;
cout << "(1): "<<qu[-1] <<endl;[/code]
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this