سؤال

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

example:

int time = CFAbsoluteGetCurrent();
int lastDigit;
هل كانت مفيدة؟

المحلول

Use modulo:

int lastDigit = time % 10;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top