-
May 8th, 2013, 09:16 PM
#1
[RESOLVED] only works with cout?
hey, I ran into this, what I'm calling "quantum problem" because it's like quantum mechanics, when I'm looking at
what my program is doing, it works fine, but if I want to hide the data, it doesn't work.
I can't show you the original code since it's for a business, but I've managed to replicate it with this simple program:
Code:
#include <Windows.h>
#include <iostream>
using namespace std;
long big[999999];
int x = 1;
int main()
{
while(true)
{
big[x] = x;
x = x+1;
if (GetAsyncKeyState(0x01)) break; // just included this as a simple way to exit the program.
cout << x << '\r' ; // only works when this line is included.
}
return 0;
}
this works just dandy, but if you remove the cout/comment it out. it'll get an error after a few seconds.
I'm running windows 8, using VS 2012 desktop edition.
my guess is that without the display, it calculates the data to fast, filling up the array, causing an error when it can't hold any more data.. but I can't seem to replicate that problem with the cout active.
any Idea what's causing this?
thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|