Errors in this function, dont know why
I need help, I wrote this piece of function and try to compile with gcc this code and it gives me errors like this, I am new at c language still trying to get used to it, any help or suggestions are much appreciated . thanks in advance
1- error: YES undeclared (first use in this function) inhex = YES;
2- note: each undeclared identifier is reported only once for each function it appears in
error: NO undeclared (first use in this function)
inhex = NO;
Code:
int xtoi (char hexstring[]){
int hexdigit, i, inhex, n;
i=0;
if(hexstring[i] == '0') {
++i;
if(hexstring[i] == 'x' || hexstring[i] == 'X') {
++i;
}
}
n = 0;
inhex = YES;
for(; inhex == YES; ++i) {
if(hexstring[i] >= '0' && hexstring[i] <= '9') {
hexdigit = hexstring[i] - '0';
}else if(hexstring[i] >= 'a' && hexstring[i] <= 'f') {
hexdigit = hexstring[i] - 'a' + 10;
}else if(hexstring[i] >= 'A' && hexstring[i] <= 'F') {
hexdigit = hexstring[i] -'A' + 10;
}else{
inhex = NO;
}