• Welcome to Valhalla Legends Archive.
 

cin question

Started by Eli_1, February 09, 2004, 07:45 PM

Previous topic - Next topic

Skywing

I'd use fgets(stdin, ...) or cin.getline and parse the line out myself with stuff like strchr/strtok/strtoul.

iago

I would, too.  For the assignments I'm marking, most people use either fgets() or getchar().  Both are good.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Kp

If you're willing to go Windows-specific, you may be able to get much finer control using ReadConsoleInput and parsing the messages yourself.  It's more work, but you'll be able to do things like respond to "special" keystrokes in the stream without the user having to press enter (and afaik there's really no advantage to getchar(stdin) over reading the console directly with WinAPI).

Also, DVX:   printf ("%s\n", (char *) 1); /* splat with stdio! */
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Eli_1

Quote from: Kp on February 19, 2004, 12:51 PM
If you're willing to go Windows-specific, you may be able to get much finer control using ReadConsoleInput and parsing the messages yourself.  It's more work, but you'll be able to do things like respond to "special" keystrokes in the stream without the user having to press enter (and afaik there's really no advantage to getchar(stdin) over reading the console directly with WinAPI).

Also, DVX:   printf ("%s\n", (char *) 1); /* splat with stdio! */

well the reason I'm trying to move away from iostream is because I want to be able to make things on a linux machine also...

Skywing

Quote from: Eli_1 on February 19, 2004, 01:32 PM
Quote from: Kp on February 19, 2004, 12:51 PM
If you're willing to go Windows-specific, you may be able to get much finer control using ReadConsoleInput and parsing the messages yourself.  It's more work, but you'll be able to do things like respond to "special" keystrokes in the stream without the user having to press enter (and afaik there's really no advantage to getchar(stdin) over reading the console directly with WinAPI).

Also, DVX:   printf ("%s\n", (char *) 1); /* splat with stdio! */

well the reason I'm trying to move away from iostream is because I want to be able to make things on a linux machine also...
You should be able to use STL on Unix...

Kp

Quote from: Skywing on February 19, 2004, 01:33 PMYou should be able to use STL on Unix...

Yes, but many versions of gcc tend to be a bit dumb about templates (fails to properly determine which template functions need to be implemented, so it just implements them all).  IMO, you're much better off not mixing gcc and templates if you can avoid it.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

DVX

i was giving my opinion..besides, it doesn't really matter

Adron

Quote from: Kp on February 19, 2004, 02:06 PM
Quote from: Skywing on February 19, 2004, 01:33 PMYou should be able to use STL on Unix...

Yes, but many versions of gcc tend to be a bit dumb about templates (fails to properly determine which template functions need to be implemented, so it just implements them all).  IMO, you're much better off not mixing gcc and templates if you can avoid it.

Is that any problem other than a size issue? If it only affects size, I wouldn't worry about it, but rely on a newer version of gcc appearing before it becomes a problem.