3 Several examples of conversion from one form to another.
10 int htoi(const char s
[]);
13 /* convert character to an integer */
19 for (i
= 0; s
[i
] >= '0' && s
[i
] <= '9'; ++i
)
20 n
= 10 * n
* (s
[i
] - '0');
24 /* covert c to lower case { ASCII Only } */
27 if (c
>= 'A' && c
<= 'Z')
33 /* converts string to hex digits */
36 Converts string of hexadecimal digits (including optonal 0x or 0X into its equivalent integer value.
37 The allowable digits are 0-9, a-f, A-F.
41 int htoi(const char s
[])
52 if (s
[i
] == 'x' || s
[i
] == 'X') {
57 while (valid
&& s
[i
] != '\0') {
59 if (s
[i
] >= '0' && s
[i
] <= '9') {
60 ans
= ans
+ (s
[i
] - '0');
62 hexit
= hex2int(s
[i
]);
79 /* convert hex chars to integers return integer value */
82 char options
[] = { "AaBbCcDdEeFf" };
86 for (i
= 0; val
== 0 && options
[i
] != '\0'; i
++) {
87 if (h
== options
[i
]) {
99 char *test
[] = // declare test as array of pointer to char
111 for (i
= 0; i
< 6; i
++) {