Guardian C Library Calls Reference Manual
stch_i (supplementary)
3-178 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
stch_i (supplementary)
The stch_i function converts a string of hexadecimal characters to an integer.
str_ptr
points to the string to convert.
int_ptr
points to the variable of type int where stch_i stores the converted value.
Return Value
is the number of characters scanned, or zero if *str_ptr does not begin with a valid
hexadecimal digit.
Usage Guidelines
•
The stch_i function does not skip leading space characters.
•
This function halts the conversion of the string when it encounters a character that is
not a valid hexadecimal digit.
Example
This example converts the hexadecimal string “1a2” to an integer:
#include <stdlibh>
#include <stdioh>
int main(void)
{
int num;
int count;
char *string;
string = "1a2"; /* hexadecimal for 418 */
count = stch_i(string,&num);
printf("%d",num); /* prints "418" */
}
#include <stdlibh>
int stch_i(char *str_ptr, int *int_ptr);