1 #pragma comment(compiler)
3 #pragma comment(timestamp)
7 #pragma title("antoi - char array to integer")
11 /********************************************************************/
14 /* Date: Jan 28, 1991 */
15 /* Organization: W/OSO242 - Graphics and Display Section */
16 /* Programmer: Allan Darling */
19 /* Abstract: This function will convert a character array */
20 /* (string) of length (len) into an integer. */
21 /* The integer is created via a call to the */
22 /* function atoi. This function extends the */
23 /* functionality of atoi by removing the */
24 /* requirement for a sentinal delimited string */
27 /* Input: - Pointer to an array of characters. */
28 /* - Integer indicating the number of character to include */
29 /* in the conversion. */
31 /* Output:- An integer corresponding to the value in the character */
32 /* array or INT32_MIN (-2147483647-1) if the function is */
33 /* unable to acquire system storage. */
35 /* Modification History: */
38 /********************************************************************/
45 # define INT32_MIN (-2147483647-1)
48 int antoi(char * string, int len)
64 tmpstr = (char *)malloc((len+1) * sizeof(char));
66 if (tmpstr == NULL) return INT32_MIN;
68 for (i = 0; i < len; i++)
69 tmpstr[i] = string[i];
73 retval = atoi(tmpstr);