Hexadecimal to decimal converter in C (htoi.c) Is there any way I can make this code more efficient? I'm new to C, any suggestion is welcome!

#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;math.h&gt;

#define LIMIT 1024

unsigned long htoi(char s[], int len);

int main(void){
    char line[LIMIT+1];

    int i=0;
    for(int c=0; i&lt;LIMIT-1 &amp;&amp; (c = getchar()) != '\n' &amp;&amp; c != EOF; ++i){
        line[i] = c;
    }
    line[i] = '\0';

    printf("%lu\n", htoi(line, i));
}

unsigned long htoi(char s[], int len){

    unsigned long total = 0;
    unsigned short currdigit = 0;
    int power = 0;

    for(int i=len; i&gt;-1; --i){

        if(s[i] == 'X' || s[i] == 'x' || s[i] == 0){
            continue;
        }

        if(s[i] &gt;= '0' &amp;&amp; s[i] &lt;= '9'){ // if it is a numerical char
            currdigit = s[i]-'0';
        }
        else{
            if(s[i] &gt;= 'a' &amp;&amp; s[i] &lt;= 'z'){ // if it's a lower case char
                currdigit = s[i] - 'a';
            }
            else{ // if not, then we assume it is an upper case char (should I?)
                currdigit = s[i] - 'A';
            }

            currdigit+=10;
        }

        total += (currdigit * pow(16, power));

        ++power;
    }

    return total;
}


I have a few questions as well:


The book I am using to learn C didn't reach the point of teaching pointers yet; however, I do know at least the basics. Is there any way pointers could be used in this program?
Should I make change the parameter char s[] to const char s[] since I am not changing any of its elements' values? Is that common practice?
Should I use short instead of int when I know the number won't surpass great quantities? As an instance, when developing a game, if I know my player's health is from 0 to 100, should I be using a short to store that value? And should it be unsigned as well if I know it won't be negative?
#define LIMIT 1024: magic constants should be named well. What is the limit for? You are also storing the result in an unsigned long and contain much less than 1021 hex digits (the last 3 are for 0x and the null terminator).

Operators should be spaced for better readability: int i = 0; and for (int

I'm a bit rusty with C, but I think fgets can be used instead of rolling your own getc loop

Inside htoi, a single tolower or toupper removes the need to check lowercase and capitals

if(s[i] &gt;= 'a' &amp;&amp; s[i] &lt;= 'z'): hex digits only contain 0-9 and a-f (not a-z)

pow(16, power): in this case, pow(16, power) = 1 &lt;&lt; (4 * power) (see bitshifts). I would split the 4 * power so that it is more clear what it represents (digit position)

Some changes to the algorithm are necessary: input of 1z00x000 gives 53477376 and kibe gives 86718. I would check if there is a leading 0x and if there is, to skip it (if not, return an error code)

if not, then we assume it is an upper case char and And should it be unsigned as well if I know it won't be negative: with your code, I can get currdigit to underflow by choosing (for example) a plus sign as input.