473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Hi, I have the following problem:

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
Nov 14 '05 #1
4 1240
On Wed, 21 Jul 2004 20:31:37 GMT, voidstar <vo******@tin.it> wrote:
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.

--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 14 '05 #2
>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
Nov 14 '05 #3
voidstar wrote:

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
Nov 14 '05 #4

"voidstar" <vo******@tin.it> wrote in message

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.
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
1
by: timVerizon | last post by:
Hoping someone can help here.. Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions ERROR SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: '', type...
6
by: mahesh | last post by:
Hi friend, I am in deep trouble, I need to change the string in following format " 1.55576+2" in the floating point notation. that is i should have 155.576 as my output. Please suggest some...
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
1
by: parasuit | last post by:
HI every body I need following programs for java .........please urgent i m biggner so help me................but urgent Problem # 1 An integer is said to be prime if it is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.