Hi, I have the following problem:

V

voidstar

Hi, I have the following problem:

I use "getch" to monitor keypresses and the I use "cin" to input a
string.

When I type in 'y', the 'y' character appears, so I need to hit backspace
before typing the string.

c = getch();
cin >> str;

Please help me!
Thanks in advance
voidstar
 
A

Alan Balmer

Hi, I have the following problem:

I use "getch" to monitor keypresses and the I use "cin" to input a
string.

When I type in 'y', the 'y' character appears, so I need to hit backspace
before typing the string.

c = getch();
cin >> str;

Please help me!
Thanks in advance
voidstar

Your problem here is that the first line is implementation-specific
and the second is C++. Neither is on topic in this group, which
discusses the Standard C language.

Try a newsgroup which deals with the platform you're writing for.
 
G

Gordon Burditt

Hi, I have the following problem:
I use "getch" to monitor keypresses and the I use "cin" to input a
string.

Since neither of these exist in C, you have a large problem. If
you want to write C, stop doing both of these things. C++ is
discussed in comp.lang.c++, next door.
When I type in 'y', the 'y' character appears, so I need to hit backspace
before typing the string.

Why?

Gordon L. Burditt
 
D

Default User

voidstar said:
Hi, I have the following problem:

I use "getch" to monitor keypresses

No such thing in C. It is an extension offered by some compilers. Please
find a newsgroup dedicated to your platform.
and the I use "cin" to input a
string.


That is a C++ construct. See comp.lang.c++.




Brian Rodenborn
 
M

Malcolm

voidstar said:
I use "getch" to monitor keypresses and the I use "cin" to input a
string.

When I type in 'y', the 'y' character appears, so I need to hit backspace
before typing the string.

c = getch();
cin >> str;
cin is a sin on comp.lang.c.

You cannot monitor keypresses in ANSI C. All input comes in lines fed into
stdin by the user.

I would suggest that you look at scanf() and fgets() and learn how to handle
C IO. Then go onto C++ streams, which are arguably easier to use but do a
lot more work behind your back.
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top