[BORLAND C++ free command line compiler]
[console program]
Ok, until a few hours ago, I had a perfectly functional program. My header contains most of the functions, I debugged enough to find a rough source;
Code:
void ClearAsyncArrowBuffer() {
if(GetAsyncKeyState(VK_UP)&SHRT_MAX)
cout << "";
if(GetAsyncKeyState(VK_DOWN)&SHRT_MAX)
cout << "";
if(GetAsyncKeyState(VK_LEFT)&SHRT_MAX)
cout << "";
if(GetAsyncKeyState(VK_RIGHT)&SHRT_MAX)
cout << "";
}
int ATCONFIRM() {
int x;
ClearAsyncArrowBuffer();
for(x=0; x <= 1000; x++)
if(GetAsyncKeyState(VK_LEFT)&SHRT_MAX)
return 1;
else
Sleep(10);
return 0;
}
int Save() {
string MAP;
char Saveme[1];
DWORD reader;
COORD Pos;
unsigned int x_pos, y_pos, x00;
x00=0;
for(y_pos=0; y_pos <= 24; y_pos++)
for(x_pos=0; x_pos <= 79; x_pos++) {
Pos.X = x_pos;
Pos.Y = y_pos;
ReadConsoleOutputCharacter(hOt, &Saveme[0], 1, Pos, &reader);
if(x_pos == 79)
MAP[x00] = 'W';
else
MAP[x00] = Saveme[0];
x00++;
}
if(!ATCONFIRM())
return 0;
ofstream file_out("C:\\1.txt");
if(!file_out) {
MessageBox(NULL, "Error[2], could not open file!", "Error[2]", MB_OK);
return -1;
}
for(x00=0; x00 <= MAP.length(); x00++)
if(MAP[x00] == 'W')
file_out << '\n';
else
file_out << MAP[x00];
file_out.close();
MessageBox(NULL, "File Saved Successfuly.", "Sucess!", MB_OK);
return 1;
}
The part in red is what I have found to be the problem, I'll post the whole code at the end of this post though.
Ok, I have tried a fair bit, this should unless I'm mistaken, save what you're currently seeing in the console. My problem is, when I press the right arrow, then left (which is how the program knows you want to save) it just stops. The whole program exits. But, in that part of code, I have no exit calls, and no breaks either. I cant figure why this happens.
*I know this is absolutely 100% nonportable, but I'm sort of addicted to windows.h -,-*
And, the header pritty big... I'll post it if I need to, but I'd rather not, the .cpp file just calls the header functions so its pritty useless to post.
I'm 99% sure that save function is the problem. (My debugging shows that it successfuly entered into the save function, but it never actualy continued afterwards...?)
Well, thank you very much, this is a really weird error.
*I would post my error, but I'm not getting one, it just stops the program.*