470,874 Members | 1,400 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

Return key not displaying

The return key is a special character. I'm trying to display the
return key by coping the special character into a character array.
When I run my app, the return key (arrow) does not display. Can
someone offer advice on displaying return, backspace, etc?

Thanks.

May 25 '06 #1
2 1575
lakepeir wrote:
The return key is a special character. I'm trying to display the
return key by coping the special character into a character array.
When I run my app, the return key (arrow) does not display. Can
someone offer advice on displaying return, backspace, etc?


C++ offers only very primitive data entry systems. You can borrow fgets()
from C, or use std::getline(). In a pinch, cin >> might work. And
C++ defines no graphics system to display these codes as anything.

For best results, use Google to find a newsgroup that covers your
platform. Nearly everything about GUIs and data entry are
platform-specific. If you use windows, try
news:microsoft.public.vc.language .

--
Phlip

May 25 '06 #2
la******@yahoo.com wrote:
The return key is a special character. I'm trying to display the
return key by coping the special character into a character array.
When I run my app, the return key (arrow) does not display. Can
someone offer advice on displaying return, backspace, etc?

Thanks.


I think the following code uses an extension, but its commonly
implemented, one way or another:
Works in VC7.1 and gcc 4.0

#include <conio.h>
#include <iostream>

#ifdef __GNUC__
inline int _getch(){return getch();}
#endif

int main()
{
int ch;
do{
ch = _getch();
std::cout << ch << '\n';
} while( ch != '\n' );

}
(BTW both gcc and VC++ think Ctrl + return == '\n' on my keyboard, at
least in windows)

regards
Andy Little

May 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Aaron Reimann | last post: by
2 posts views Thread by Carole MacDonald | last post: by
5 posts views Thread by Nomen Nescio | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.