Return key not displaying

L

lakepeir

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.
 
P

phlip

lakepeir said:
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
.
 
K

kwikius

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top