3 /********************************************************************/
6 /* Date: Jan 28, 1991 */
7 /* Organization: W/OSO242 - Graphics and Display Section */
8 /* Programmer: Allan Darling */
11 /* Abstract: This function will convert a character array */
12 /* (string) of length (len) into an integer. */
13 /* The integer is created via a call to the */
14 /* function atoi. This function extends the */
15 /* functionality of atoi by removing the */
16 /* requirement for a sentinal delimited string */
19 /* Input: - Pointer to an array of characters. */
20 /* - Integer indicating the number of character to include */
21 /* in the conversion. */
23 /* Output:- An integer corresponding to the value in the character */
24 /* array or INT32_MIN (-2147483647-1) if the function is */
25 /* unable to acquire system storage. */
27 /* Modification History: */
30 /********************************************************************/
37 # define INT32_MIN (-2147483647-1)
40 int antoi(char * string, int len)
56 tmpstr = (char *)malloc((len+1) * sizeof(char));
58 if (tmpstr == NULL) return INT32_MIN;
60 for (i = 0; i < len; i++)
61 tmpstr[i] = string[i];
65 retval = atoi(tmpstr);