From ec3c37d1d40d7b288584c234f4c3e7a600f2353d Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 3 Apr 2025 12:30:34 -0400 Subject: new libs --- lib/str2int.c | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 lib/str2int.c (limited to 'lib/str2int.c') diff --git a/lib/str2int.c b/lib/str2int.c deleted file mode 100644 index ce28a7a..0000000 --- a/lib/str2int.c +++ /dev/null @@ -1,52 +0,0 @@ -/** -** @file str2int.c -** -** @author Numerous CSCI-452 classes -** -** @brief C implementations of common library functions -*/ - -#ifndef STR2INT_SRC_INC -#define STR2INT_SRC_INC - -#include - -#include - -/** -** str2int(str,base) - convert a string to a number in the specified base -** -** @param str The string to examine -** @param base The radix to use in the conversion -** -** @return The converted integer -*/ -int str2int(register const char *str, register int base) -{ - register int num = 0; - register char bchar = '9'; - int sign = 1; - - // check for leading '-' - if (*str == '-') { - sign = -1; - ++str; - } - - if (base != 10) { - bchar = '0' + base - 1; - } - - // iterate through the characters - while (*str) { - if (*str < '0' || *str > bchar) - break; - num = num * base + *str - '0'; - ++str; - } - - // return the converted value - return (num * sign); -} - -#endif -- cgit v1.2.3-freya