View Single Post
Old 07-10-2002, 12:54 AM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,721
redhead is on a distinguished road
This is missleading... But I guess C++ is ugly that way..

A small test revealed, if the input isn't an int, the int value will be set to less than INT_MIN/2 So the disturbing part is, what if the user chose to input INT_MIN+2 then we can't be sure wether its a valid input or not... Not even errno is set to anything..

Oddly enough, theres alot of setf() flags, that can turn input into truely boolean or decimal but none defined for a simple int...

Guess the last thing todo, is use a fscanf() on stdin, to make sure its a valid int you're getting..
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote