You are here:

C++/isxdigit()

Advertisement


Question
how can i make the isxdigit() function by myself?

Answer
Look at the following to see how professionals define such function:
http://www.greatsnakes.com/Sepal/d0/d7/isxdigit_8c-source.html

However, if you don't understand what they are doing, you just need to check if the digit is in this range:

(ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F')

If you let user enter lower case, then add:

|| (ch >= 'a' && ch <= 'f')

This was for one digit (one character). For a number, you need to do that check for every character.

I hope it is clear now.

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Sam

Expertise

You may ask me about simple to complicated C/C++ programming methods/style and most like questions about network programming in C++.

Experience

I'm a professional programer in C++ and network/internet programming.

©2016 About.com. All rights reserved.