Hi Guys
I wrote a simple program that takes in a string of 8 bytes representing a 32 bit 4byte hex word. The purpose of the function is to convert the string into a hex number, can someone please tell me what i am doing wrong, please!! ***hexstr_ptr is the character string holding the 8bytes representing a 32 bit hex word
Code:int nxt_char, cmdopt, cmdport, nibble0, nibble1;//, index; const char hex_str[] = "0123456789ABCDEF"; hex_value = 0; for ( int j = 0; j <= 7; j++ ) { //compare the two strings and convert string to hex for ( int i = 0; i <= 15; i++ ) { if ( hex_str[i] == hexstr_ptr[j] ) { hex_value = ( hex_value << 4 ) | i; break; } } } return ( hex_value );



LinkBack URL
About LinkBacks



