# stupid question about ascii characters

**URL:** <https://community.unix.com/t/stupid-question-about-ascii-characters/150104>\
**Category:** Programming\
**Created:** [September 28, 2004, 3:41pm UTC](https://community.unix.com/t/stupid-question-about-ascii-characters/150104 "2004-09-28T15:41:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jalburger](https://community.unix.com/letter_avatar/jalburger/32/5_5575768a8748004e209b776fc1b2916d.png) [@jalburger](https://community.unix.com/u/jalburger)\
**Post date:** [September 28, 2004, 3:41pm UTC](https://community.unix.com/t/stupid-question-about-ascii-characters/150104/1 "2004-09-28T15:41:45Z")

</div>

i know it's out there, but I cannot remember how to check if a given ascii character string contains all digits or not ... any ideas?

ie...function("123") --\> OK  
function("NOT\_A\_NUMBER") --\> returns error

thanks!!

---

<div class="post-metadata">

**Author:** ![Perderabo](https://community.unix.com/user_avatar/community.unix.com/perderabo/32/27_2.png) [@Perderabo](https://community.unix.com/u/Perderabo)\
**Post date:** [September 28, 2004, 3:53pm UTC](https://community.unix.com/t/stupid-question-about-ascii-characters/150104/2 "2004-09-28T15:53:23Z")

</div>

isdigit will test a single character. I guess you could try strtol on the string and see what happens. Or maybe strspn() with a second string of "0123456789"? I don't think there is a function that does precisely what you want. Of course, it would be a snap to write one.

---

<div class="post-metadata">

**Author:** ![jalburger](https://community.unix.com/letter_avatar/jalburger/32/5_5575768a8748004e209b776fc1b2916d.png) [@jalburger](https://community.unix.com/u/jalburger)\
**Post date:** [September 28, 2004, 3:56pm UTC](https://community.unix.com/t/stupid-question-about-ascii-characters/150104/3 "2004-09-28T15:56:56Z")

</div>

i think isdigit() was the function I was trying to remember (though it doesn't work completely the way I described)

thanks!!
