SA-MP Forums Archive
[C++ scripting help] Cheking if character or digit? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: [C++ scripting help] Cheking if character or digit? (/showthread.php?tid=512048)



[C++ scripting help] Cheking if character or digit? - davve95 - 08.05.2014

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.


Re: [C++ scripting help] Cheking if character or digit? - gtakillerIV - 08.05.2014

You could use isdigit.


Re: [C++ scripting help] Cheking if character or digit? - Mauzen - 08.05.2014

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.


Re: [C++ scripting help] Cheking if character or digit? - davve95 - 09.05.2014

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.


Re: [C++ scripting help] Cheking if character or digit? - Vince - 09.05.2014

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



Re: [C++ scripting help] Cheking if character or digit? - caoraivoso3 - 09.05.2014

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;
   
}