CARM User's Guide

Discontinued

toint

Summary
#include <ctype.h>

int toint (
  int c);   /* digit to convert */
Description

The toint function interprets c as a single-digit hexadecimal value. ASCII characters '0'-'9' generate values 0-9. ASCII characters 'A'-'F' and 'a'-'f' generate values 10-15. If the value of c is not a hexadecimal digit, the function returns –1.

Return Value

The toint function returns the value of the ASCII hexadecimal character c.

See Also

toascii

Example
#include <ctype.h>
#include <stdio.h> /* for getchar */

void tst_toint (void) {
  unsigned long l;
  unsigned char k;

  for (l = 0; isdigit (k = getchar ()); l *= 10) {
    l += toint (k);
  }
}