I'm trying to feed a single char (as an int) to this function an then get back the hex value but I"m getting complier errors...
gives me:Code:254>int hex_to_int(int c) 255>{ 256> 257> if((c - (int)'0' >= 0 )&&(c - (int)'0' < 10)) 258> { 259> return (c - (int)'0'); 260> } 261> 262> char hexalpha[] = "aAbBcCdDeEfF"; 263> int i; 264> int answer = 0; 265> 266> for(i = 0; answer == 0 && hexalpha[i] != '\0'; i++) 267> { 268> if(hexalpha[i] == c) 269> { 270> answer = 10 + (i / 2); 271> } 272> } 273> 274> return answer; 275>}
C:\uiox_dev\UIOX Sources\Rcl.c(262) : error C2143: syntax error : missing ';' before 'type'
C:\uiox_dev\UIOX Sources\Rcl.c(263) : error C2143: syntax error : missing ';' before 'type'
C:\uiox_dev\UIOX Sources\Rcl.c(264) : error C2143: syntax error : missing ';' before 'type'
C:\uiox_dev\UIOX Sources\Rcl.c(266) : error C2065: 'i' : undeclared identifier
C:\uiox_dev\UIOX Sources\Rcl.c(266) : error C2065: 'answer' : undeclared identifier
C:\uiox_dev\UIOX Sources\Rcl.c(266) : error C2065: 'hexalpha' : undeclared identifier
C:\uiox_dev\UIOX Sources\Rcl.c(266) : error C2109: subscript requires array or pointer type
C:\uiox_dev\UIOX Sources\Rcl.c(268) : error C2109: subscript requires array or pointer type
any ideas where these are coming from?
thanks




Reply With Quote