Re: Array of bytes to string
So what's the programming question? This isn't the place to highlight some code you're written!!!!!:mad:
Re: Array of bytes to string
I'm sorry :( the moderator, can move this to the correct section?
Re: Array of bytes to string
hhhhhhÿÿÿÿi eightyfive,
The real advantage to using a look-up table is that the code will run much faster than doing a bunch of calculations. However, doing a linear scan through the table to find its inverse function, as you have done in Test2(), will run very slowly. You could use another look-up table to convert the hexadecimal characters back to decimal numbers.
Code:
void Test2(char* cadena_de_bytes, BYTE* cadena_de_bytes_resultante)
{
static BYTE Tabla[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
int Position;
int Length_de_bytes_resultante; // :)
Position = 0;
while (cadena_de_bytes[Position] != '\0')
{
cadena_de_bytes_resultante[Position >> 1] = (Tabla[cadena_de_bytes[Position]] << 4) + Tabla[cadena_de_bytes[Position + 1]];
Position = Position + 2;
}
Length_de_bytes_resultante = Position >> 1;
for (Position = 0; Position < Length_de_bytes_resultante; Position = Position + 1)
{
printf("%02X", cadena_de_bytes_resultante[Position]);
}
printf("\n");
}
Note: Calling the strlen() function inside the test condition of the for loop means it will be called for every iteration of the loop. This is very inefficient since the strlen() function must loop through the character array every time to determine the length. If you are going to use the strlen() function, assign the result to a variable and use that variable in the loop's test condition.
Re: Array of bytes to string
copy CADO-VN1.COM de xem chi tiet huong dan
huong dan ca cuoc tren mang
huong dan ca cuoc online
huong dan ca do bong da
huong dan ca cuoc bong da
huong dan ca do tren mang
huong dan ca cuoc tren mang
huong dan ca cuoc bong da
Re: Array of bytes to string
yeahh well about that of the strlen, i knew that it would be made every loop, but this is actually the second version of this program.. see the previous version:
http://foro.elhacker.net/programacio...t383814.0.html
perhaps I didn't care about taht i'm not sure
great idea with the second function!, the first function uses the table to "lookup", but the second didn't manage to make that. The idea was anyways to make a program to manage this conversion, for a person that doesn't know about bytes managing, that's why my code hasn't applied the normal logic to handle byte to decimal convertion, and the inverse operation.