Computer Science Canada Negatives |
Author: | AK.E [ Fri Jan 19, 2007 2:10 pm ] | ||
Post subject: | Negatives | ||
I have a program in which I want to get a number but prevent them from entering negatives. I know I can simply use if number < 0 then... but that only works for the first time. Let's say someone enters -5.. it won't except it.. but when they enter 100 then -5 it will because the number will be 95 which is above 0. Here's my code:
|
Author: | Clayton [ Fri Jan 19, 2007 4:02 pm ] | ||
Post subject: | Re: Negatives | ||
use natural numbers instead of integers
|
Author: | Cervantes [ Fri Jan 19, 2007 5:03 pm ] |
Post subject: | Re: Negatives |
There are strnat and strnatok functions, yes? Using those would solve your problem. |