This is possibly a very basic question, but how to check the second or third value of of an int variable? Am I supposed to use on of them string functions or is there a simpler way?

Printable View

- 08-02-2009JefffCheck certain positions of an int?
This is possibly a very basic question, but how to check the second or third value of of an int variable? Am I supposed to use on of them string functions or is there a simpler way?

- 08-02-2009Spidey
What do you mean by sting functions on an int ?

Also, yes getting the third or fourth position is as simple as reaching the third or fourth digit which you should know how to do from math class. - 08-02-2009Jefff
I am trying to write a function that checks certain positions of an int and the value of it. I would like to know how to do this. And what do you mean with math class?

- 08-02-2009Spidey
What I meant was that there is a simple formula to get each digit of an int. Think about it, its pretty easy actually.

Supposing your number was 100

then the hundredths place digit is 1

and the tenths place digit is 0

and the digit at the ones place is 0

Now how would you write a program to do that ? - 08-02-2009Jefff
Ok got it, Modulus did the trick. thx for the wink in the right direction.