C/Objective-C read and get last digit of integer?

Daniel says Reinstate Monica picture Daniel says Reinstate Monica · Dec 30, 2010 · Viewed 13.6k times · Source

How can i get the last digit of an integer (or NSInteger) outputted to integer?

example:

int time = CFAbsoluteGetCurrent();
int lastDigit;

Answer

Georg Fritzsche picture Georg Fritzsche · Dec 30, 2010

Use modulo:

int lastDigit = time % 10;