You are here:



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

Hi maki:
  I hope u'll be fine. I assume ur function takes a char parameter. Lets call it ch. So that now ur function's prototype look like:
   isxdigit(char ch)

What u need to do is to convert the ch to an int like
 int code = ch;
Doing so will convert the decimal representation os the ASCII code of the given character in the code variable.
Now if ch was holding a digit, its corresponding value in code must be between 48(that represents 0)  and  57(that represents 9). So u just need to check whether the code variable has a values bw 48 and 57(boundaries inclusive).

 Below is the sample code, i wrote for u:
#include <iostream.h>
#include <conio.h>

void main()

  char ch;
  cout<<"Enter a character:";

  int code = ch;
  if(code >=48  &&  code <= 57)
     cout<<"The entered character is a digit";
     cout<<"The entered character is not a digit";


Plz. feel free to ask a followup, if u need to.
Thanks for contacting me


All Answers

Answers by Expert:

Ask Experts




I can answer any questions that range from the very basics of c++ to the advanced topics like polymorphism, inheritance, composition, multiple inheritance and templates. I can also answer almost every type of questions about c++ data structures like stack, queue, circular queue, linklist(single, double, circular), binary trees, binary search trees, avl trees, 2-3 and 2-3-4 trees. I dont have much experience of mfc and creating guis in visual c++, so plz. dont ask me questions about that.


I'm working in c++ since the last 6 years. I've good working skills specially in the advanced topics like inheritance, polymorphism and all type of c++ data structures.

©2017 All rights reserved.