help-gplusplus
[Top][All Lists]
Advanced

[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:54:38 +0000 (UTC)
User-agent: Pan/0.132 (Waxed in Black)

On Fri, 02 Nov 2007 09:33:56 +0100, Stefan Kristensen wrote:

[...]

> I use fgets() to read a string, but don't want to pertain the newline
> charcter. In the old days, I used flushall(), but that doesn't seem to
> be valid either. What do I do here?

The preferred C++ way would be to use the std::string class (defined in 
header <string>). You might then use std::getline() to read into a 
string. It handles newlines sensibly.

In general std::string is *much* nicer than faffing about with char* (the 
C way). Again, check your text book.

Cheers,

-- 
Lionel B


reply via email to

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