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?
This is a discussion on Check certain positions of an int? within the C++ Programming forums, part of the General Programming Boards category; This is possibly a very basic question, but how to check the second or third value of 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?
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.
Spidey out!
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?
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 ?
Spidey out!
Ok got it, Modulus did the trick. thx for the wink in the right direction.