[C++ scripting help] Cheking if character or digit?
#1

Hi!


How can I check in C++ if it's a digit or a character?.

On the simplest way?. I couldn't figure it out. Thanks a lot in in advance.
Reply
#2

You could use isdigit.
Reply
#3

Without using any available functions you would probably check if the characters value is within the range of numbers or alphabetical characters. You get these ranges from a symbol table, ascii is the common one.
Reply
#4

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Without using any available functions you would probably check if the characters value is within the range of numbers or alphabetical characters. You get these ranges from a symbol table, ascii is the common one.
Thanks!.

Can you give some example?, I'm not completely sure how it works or should look like.

Didn't found much on ****** either.
Reply
#5

Probably similar to how it's done in Pawn;
Код:
return (char >= '0' && char <= '9');
Reply
#6

yeah

use this fuction i made for pawn
pawn Код:
IsNumero(const string[])
{
    for (new cell = 0, tamanho = strlen(string); cell < tamanho; cell++)
    {
        if (string[cell] <= '9' || string[cell] >= '0') return 1;
    }
    return 0;
   
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)