well,

it just does not make any sense...

here is my code

Code:
#include<stdio.h>

int plain[3],key[3][3],cip[3];

int conv_to_num(char p)
{
    int val=0;
    val=(int) p;
    printf("p=%c,val=%d\n",p,val);
    val=val-97;
    printf("val=%d\n",val);
    return val;
}

void enc()
{
    char key1[9],plain1[3],cip1[3];
    int temp[9],i=0,j=0,k=0;
    k=0;
    printf("Enter the key matrix in the form of a string==");
   gets(key1);
    printf("Enter the plain text matrix in the form of a string==");
    gets(plain1);
    for(i=0;i<9;i++)
    {
        printf("key[%d]=%c\n",i,key1[i]);
        temp[i]=conv_to_num(key1[i]);
        printf("i=%d,%d\n",i,temp[i]);
    }

     for(i=0;i<3;i++)
    {
        plain[i]=conv_to_num(plain1[i]);    
        printf("%d\n",plain[i]);    
    }
}

int main()
{
     enc();
     return 0;
}
this the output i get...

Code:
$ gcc ........edup.c 
/tmp/ccMKBfee.o: In function `enc':
........edup.c:(.text+0x87): warning: the `gets' function is dangerous and should not be used.
$ ./a.out
Enter the key matrix in the form of a string==asdfghjkl
Enter the plain text matrix in the form of a string==asd
key[0]=
p=,val=0
val=-97
i=0,-97 ****what the????****
key[1]=s
p=s,val=115
val=18
i=1,18
key[2]=d
p=d,val=100
val=3
i=2,3
key[3]=f
p=f,val=102
val=5
i=3,5
key[4]=g
p=g,val=103
val=6
i=4,6
key[5]=h
p=h,val=104
val=7
i=5,7
key[6]=j
p=j,val=106
val=9
i=6,9
key[7]=k
p=k,val=107
val=10
i=7,10
key[8]=l
p=l,val=108
val=11
i=8,11
p=a,val=97
val=0
0
p=s,val=115
val=18
18
p=d,val=100
val=3
3   ****Surprisingly this came out nicely*****
the problem is that the first character of the string key1 is not passed to the function "conv_to_num()", but characters of string plain1 get processed by the function correctly? how and why is this happening to me???


i m using gcc --version
gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)