dimanche 28 mai 2017

if statment fails to check a currect value

i have a function that translate a string coordiante to an int number from 0-9 now the function seems to fail to get the string A10(for example) and translte it to 0,9 maybe can some one tell me why?

Point TranslateCoordinate(char* c){
        Point newpoint;
        newpoint=malloc(sizeof(Point));
        int row=c[0];
        int collum;
        newpoint->x=row-'A';
        printf("%c%c\n",c[1],c[2]);
        if(c[1]== '1' && c[2]== '0'){
            newpoint->y=9;
            return newpoint;
        }
        collum=c[1];
        newpoint->y=collum-'1';
        return newpoint;

}

i should note that the values of the string range from 1 to 10 and from A to J

Aucun commentaire:

Enregistrer un commentaire