This is a simple atol function that i've defined
it works for 1, 2, 4, 6, 7 digit numbers. but not 3, 5, 8, 9, and 10 digit numbers.
it puzzling me, can somebody help me out?
Code:long atol (const char * nptr) { char temp [SIZE]; int i=0; int j=0; int sum =0; initialize (temp); while (isdigit(nptr[i])) { i++; } if ( i == 0 ) { return sum=-99; } else { while (j < i) { sum = sum + ((nptr[j]-48) * (pow(10,(i-j-1)))); j++; } return sum; }
[code][/code]tagged by Salem