Possible to get the first char of an integer?
#1

Was wondering how I would go about this in PAWN.
Reply
#2

pawn Код:
stock GetFirstNumber(number)
{
    new
        number_str[12],
        bool: negative;
   
    valstr(number_str, number);
    if (number < 0) negative = true;
    return (negative) ? (number_str[1]) : (number_str[0]);
}
Test:
pawn Код:
printf("%c", GetFirstNumber(654321));
printf("%c", GetFirstNumber(-54321));
and outputs:
pawn Код:
6
5
This is what you want, if I understood correct.
Reply
#3

Yes it was, thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)