How can i create a lookup table in c without using files.
for example, if the char value is 0xE4 change it to 0x37. but there are 256 original differnt values.
can you help me please.
How can i create a lookup table in c without using files.
for example, if the char value is 0xE4 change it to 0x37. but there are 256 original differnt values.
can you help me please.
--Code:char table[256] = { ... (at position 0xE4} 0x37 ... };
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
You can hard code an array into your program. If necessary, you can compute the array index from the given char value.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
so for example
and just do that for all 256 positions?Code:char table[256] = { ... (at position 0xE4) 0x37, (at position 0xE3) 0x36 ... };
Yes.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
and
"at position 0xE3" is acceptable C code?
No, you need to do something like this:
Unless you want to restrict yourself to using gcc, which allows some syntax similar to this:Code:char c[16] = { 17, 63, 12, 81, // 0..3 99, 11, 15, 44, // 4..7 ...
(and ... is not valid syntax, just that I'm too lazy to type in ALL of the data to fill 16 chars - never mind 256, just to show how something works).Code:char c[16] = { [0] = 17, [3] = 81, [1] = 63 ... }
Alternatively, write a program that generates a list of comma separated values, sya "mydata.tbl", and use this:
Code:char table[256] = { #include "mydata.tbl" };
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
thank you i fully understand now