use %d and getch on c++

I made this C code then I want to make C++ version, i remember i can't use % on C++
I want to read input then convert it to ascii number

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
#include <conio.h>

int main()
{
    int c;

    printf( "Please strike a key..." );

    c = getch();

         printf( "Normal keystroke for: %d\n", c );

	getchar();
     return 0;
}


can't print %d on C++ use cout, and I don't know what is getch(); on C++...
please help me out here
Last edited on
Scott Meyers prefers the use of <iostream> to stdio.h, so I would take his advice. If that's not out of the question, then try using
1
2
3
cin >> c;
//instead of
c = getch( );


if that's out of the question then I'm sure you could do it a different way.
I want to make snake game... then the input is ASDW as the arrow key...
getch convert that key to ascii... then I can use it on process
I can't use cin >> on real time ... because to get value with cin, I must press enter to finish it
I see, I didn't get that at first. Can you use Win32 api stuff? or is this going to non-windows only?
Topic archived. No new replies allowed.