开发者

Getting a character and printing it in VC++

开发者 https://www.devze.com 2022-12-28 15:52 出处:网络
I have a problem getting a character from the user in VC++.the function i want to use uses the char format so when i get the input using getch() it gives me an error that can\'t convert \'int\' t开发者

I have a problem getting a character from the user in VC++.the function i want to use uses the char format so when i get the input using getch() it gives me an error that can't convert 'int' t开发者_如何转开发o 'char'. could someone please help me how to get the input in char format please?

edit:

char key1[10]; 
key1=getch(); 
Main.draw_text(key1,120+(i*40),250,White,Black,20);


you would be better off editing your post instead of posting a code snippet in a comment.

Anyway, from the code it looks like you think getch() return a string, but it returns only one char, to get a string you need to use for instance

gets(key1);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号