[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [G++ n00b] getche() in G++ ?

From: Lionel B
Subject: Re: [G++ n00b] getche() in G++ ?
Date: Fri, 2 Nov 2007 10:47:44 +0000 (UTC)
User-agent: Pan/0.132 (Waxed in Black)

On Fri, 02 Nov 2007 11:17:17 +0100, Stefan Kristensen wrote:

>>> getchar() is close, but not exactly equivalent. Reading keyboard
>>> *immediately* (without waiting for carriage return) is rather tricky
>>> on UNIX.
>> Indeed it is... I wrote this routine some time ago (works on Linux, not
>> sure about FreeBSD). It uses "termios" routines to put stdin
>> (temporarily) in "raw" mode:
>> <snip prgram />
> Thanks. It works on FreeBSD as well :-)
> When compiling with g++, it warns me that <iostream.h> is deprecated,
> but when using <iostream> I get an error that cout is undefined. Also,
> there is no man for cout. Should I use something else in stead of cout?

You should indeed be including <iostream> rather than <iostream.h>. Then, 
be aware that most (all?) of the standard headers - i.e. the ones without 
the ".h" - put everything in the namespace "std", so e.g. you have to 
reference cout as std::cout.

BTW cout is a standard library class (it incorporates the functionality 
of stdout and much more), so you won't find a man page for it, but you 
will certainly find it in your C++ textbook, probably under I/O stream 
classes or somesuch. Read up on namespaces too.

It's a steep learning curve, but hands-on is a good approach :)

Good luck,

Lionel B

reply via email to

[Prev in Thread] Current Thread [Next in Thread]