Simplifying function I'm making a chess game. On the board the columns go from a-h and rows from 8-1. I made this simple function so when someone inputs 'a' for the row it will give me the right row on an array same goes for columns, 7a would be [1][0]. Is there an easier way someone could point out for me? 

Thanks in advance.

update:added small working sample of function.

#include &lt;stdio.h&gt;


int getColRow(char input)
{
    int val = 0;

    switch (input)
    {
    //row
    case 97:
        val = 0;
        break;
    case 98:
        val = 1;
        break;
    case 99:
        val = 2;
        break;
    case 100:
       val = 3;
       break;
    case 101:
       val = 4;
       break;
    case 102:
       val = 5;
       break;
    case 103:
       val = 6;
       break;
    case 104:
        val = 7;
        break;
    //col
    case 49:
        val = 7;
       break;
    case 50:
        val = 6;
        break;
    case 51:
        val = 5;
        break;
    case 52:
        val = 4;
        break;
    case 53:
        val = 3;
        break;
    case 54:
        val = 2;
        break;
    case 55:
        val = 1;
        break;
    case 56:
        val = 0;
        break;
    default:
        break;
    }
    return val;
    }

    int main(int argc, char *argv[])
    {
    char a = 'a';
    char b = 'b';
    char c = 'c';
    char d = 'd';
    char e = 'e';
    char f = 'f';
    char g = 'g';
    char h = 'h';


    char one = '1';
    char two = '2';
    char three = '3';
    char four = '4';
    char five = '5';
    char six = '6';
    char seven = '7';
    char eight = '8';


    printf("value of %c is %d ",a,getColRow(a));
    printf("\nvalue of %c is %d ",b,getColRow(b));
    printf("\nvalue of %c is %d ",c,getColRow(c));
    printf("\nvalue of %c is %d ",d,getColRow(d));
    printf("\nvalue of %c is %d ",e,getColRow(e));
    printf("\nvalue of %c is %d ",f,getColRow(f));
    printf("\nvalue of %c is %d ",g,getColRow(g));
    printf("\nvalue of %c is %d \n",h,getColRow(h));

    printf("\nvalue of %c is %d ",one,getColRow(one));
    printf("\nvalue of %c is %d ",two,getColRow(two));
    printf("\nvalue of %c is %d ",three,getColRow(three));
    printf("\nvalue of %c is %d ",four,getColRow(four));
    printf("\nvalue of %c is %d ",five,getColRow(five));
    printf("\nvalue of %c is %d ",six,getColRow(six));
    printf("\nvalue of %c is %d ",seven,getColRow(seven));
    printf("\nvalue of %c is %d \n",eight,getColRow(eight));

    return 0;
}
What you are doing is very basic, and the question really belongs on stackoverflow.com, but it has probably already been answered there, and therefore would be marked as a duplicate.

As I mentioned in the comment, this can be done using simple subtraction of characters when you include ctype.h&gt;, you don't need a switch statement or anything that complcated. The example below should execute faster than the version with the switch statement, and it is a lot less code.

#include &lt;ctype.h&gt;

int getColRow(char input)
{
    int val = 0;
    unsigned char testValue = (unsigned char) input;

    if (isdigit(testValue))
    {
        return testValue - '0';
    }
    else if (isalpha(testValue))
    {
        testValue = tolower(testValue);
        return testValue - 'a';
    }

    fprintf(stderr, "Invalid character %c in getColRow(char input)\n", input);
    return val;
}


Most of the functions / macros in ctype.h take unsigned integers, and it is safer to use unsigned values. The unsigned char should automatically be promoted to an unsigned integer.