[Wylug-help] C++ code

David Pashley wylug-help at davidpashley.com
Thu, 31 Oct 2002 09:56:45 +0000


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 28 October 2002 12:10 am, Roger Greenwood wrote:
> Philip Wyett wrote:
> > Hi,
> >
> > fflush(stdin); may help you once input has been taken and it's contents
> > can be safely dumped. I would suggest you look at the whole code as it
> > is hybrid and never much welcomed by many, especially C++ coders.
> >
> > Regards
> >
> > Philip Wyett
>
> Good point. By hybrid you mean C/C++? This comes from learning pascal
> first, then C, then some C++ stuff, all within a few months.
>
You should not mix C and C++ IO as things can get very confused (as you appear
to be finding out)

>
> fflush didn't work by the way. I will keep looking.
>
> p.s. What is a good way (best way?) to get a single character input
> (e.g. y/n) ?
>

string foo;
foo = getline(cin);
char resp = foo[0];

You may want to check the getline function, and you may want some error
checking, but that should work.

- --
David Pashley
david@davidpashley.com
Nihil curo de ista tua stulta superstitione.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE9wP5dYsCKa6wDNXYRAi1mAKClZPkSBEN4N7uoSgy6pOxT/tbNzwCdFtNj
o0Th2G5szQXE7VAUA3/H2N8=
=GSUM
-----END PGP SIGNATURE-----