No output in win32 console [VCPP2012]

Hello cpp com!

I want to create a console program displaying all my key presses. So I created a script including all important things. But what is wrong? No console-cursor is displayed and no text too. Can anybody help me please?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <conio.h>
#include <Windows.h>
#include <stdio.h>
#include <iostream>

bool bGetAsyncKeyState( int iKey );
void OutputPressedKeys( int ia[255][2] );

int main( void ) {
	
	int iaKeyPressed[256][2]; 

	//printf( "%i", GetAsyncKeyState( VK_F5 ) );

	//-32768
	while ( true ) {

		for ( int i = 0; i == 255; i++ ) {

			if ( bGetAsyncKeyState( i ) ) {

				iaKeyPressed[i][0] = 1;
				iaKeyPressed[i][1] = 0; //timecode or timer handle

				printf( "%i", i );

			} else {

				iaKeyPressed[i][0] = 0;

			}

		}

		OutputPressedKeys( iaKeyPressed );

	}
	

	while (true)
	{

	}

}

bool bGetAsyncKeyState( int iKey ) {

	int iKeyPress = GetAsyncKeyState( iKey );

	if ( iKeyPress == -32768 ) {

		return true;

	} else if ( iKeyPress == 0 ) {

		return false;

	}
	
	return false;

}

void OutputPressedKeys( int ia[255][2] ) {

	for ( int i = 0; i == 255; i++ ) {

		if ( ia[i][0] == 1 ) {

			printf( "pressed key: %i; ", i );

		}

	}

	printf( "\n" );

}


Thank you!
You have gotten yourself into an infinite loop on line 16. The while(true) statement doesn't actually execute your for loop, because i doesn't start off as 255 and thus never gets a chance to be incremented, so you just output the keys you have input so far: to be precise: nothing. Try changing the comparison for the for loop to != or <.
@NT3
Thank you! That worked pretty well.
Topic archived. No new replies allowed.