hi everyone,

I would just like to ask what (long)table_1 means? The table_1 is defined below. I do get a value of 4395176 with this code

printf("table 1 is %d\n", table_1);

But i dont know what operation was done? Can someone please help

unsigned char table_1[256] = {
0x08, 0xCB, 0x54, 0xCF, 0x97, 0x53, 0x59, 0xF1,
0x66, 0xEC, 0xDB, 0x1B, 0xB1, 0xE2, 0x36, 0xEB,
0xB3, 0x8F, 0x71, 0xA8, 0x90, 0x7D, 0xDA, 0xDC,
0x2C, 0x2F, 0xE8, 0x6A, 0x73, 0x37, 0xAE, 0xCC,
0xA1, 0x16, 0xE6, 0xFC, 0x9C, 0xA9, 0x2A, 0x3F,
0x58, 0xFD, 0x56, 0x4C, 0xA5, 0xF2, 0x33, 0x99,
0x1A, 0xB7, 0xFE, 0xA6, 0x1E, 0x32, 0x9E, 0x48,
0x03, 0x4A, 0x78, 0xEE, 0xCA, 0xC3, 0x88, 0x7A,
0xAC, 0x23, 0xAA, 0xBD, 0xDE, 0xD3, 0x67, 0x43,
0xFF, 0x64, 0x8A, 0xF9, 0x04, 0xD0, 0x7B, 0xC2,
0xBC, 0xF3, 0x89, 0x0E, 0xDD, 0xAB, 0x9D, 0x84,
0x5A, 0x62, 0x7F, 0x6D, 0x82, 0x68, 0xA3, 0xED,
0x2E, 0x07, 0x41, 0xEF, 0x2D, 0x70, 0x4F, 0x69,
0x8E, 0xE7, 0x0F, 0x11, 0x19, 0xAF, 0x31, 0xFB,
0x8D, 0x4B, 0x5F, 0x96, 0x75, 0x42, 0x6C, 0x46,
0xE4, 0x55, 0xD6, 0x3B, 0xE1, 0xD1, 0xB0, 0xB5,
0x45, 0x29, 0xC0, 0x94, 0x9F, 0xD4, 0x15, 0x17,
0x3C, 0x47, 0xC8, 0xD9, 0xC6, 0x76, 0xB9, 0x02,
0xE0, 0xC9, 0xB2, 0x01, 0xC1, 0x5D, 0x4E, 0x14,
0xF4, 0xAD, 0xB6, 0x00, 0x72, 0xF0, 0x49, 0x0D,
0xD8, 0x5E, 0x6F, 0x2B, 0x8C, 0x51, 0x83, 0xC5,
0x0A, 0x85, 0xE5, 0x38, 0x7E, 0x26, 0xEA, 0x22,
0x6B, 0x06, 0xD5, 0x8B, 0xBF, 0xC7, 0x35, 0x1D,
0xF6, 0x24, 0x28, 0xCE, 0x9B, 0x77, 0x20, 0x60,
0xF5, 0x87, 0x3D, 0x65, 0x86, 0x0C, 0xDF, 0xBA,
0x12, 0xA4, 0x3A, 0x34, 0xD7, 0xA0, 0xF8, 0x63,
0x52, 0x27, 0xB8, 0x18, 0xA7, 0x13, 0x91, 0x09,
0x93, 0x5C, 0x10, 0x9A, 0xB4, 0xE9, 0x44, 0xC4,
0x21, 0x57, 0x1C, 0x0B, 0xA2, 0x74, 0x4D, 0xBE,
0xD2, 0x1F, 0xCD, 0xE3, 0x6E, 0x7C, 0x40, 0x50,
0x39, 0x80, 0x98, 0xFA, 0x25, 0x92, 0x30, 0x5B,
0x05, 0x95, 0xBB, 0x79, 0x61, 0x3E, 0x81, 0xF7 };

>>printf("table 1 is %d\n", table_1);

That only prints the memory address of the beginning of table_1, which is an array of binary data. I have no idea what is stored in that array, you might get an idea from the program that contains the array.

Take the first item in the array 0x08

we know from the 0x it's a hexidecimal number (base 8) 0x is how you identify a hexidecimal number the 08 represents the number in decimal thats 8 in binary it's 00001000 (I won't go into how to convert between binary and hex and decimal you can Google that)

So what you've got is a list of 256 numbers.

Now table_1 is a pointer to the start of the array of numbers in RAM
%d tells printf to interpret the second argument as an integer.
so the program prints the RAM address of the start of the array table_1 is pointing to as an integer .

Everything is numbers to a computer, but they can be interpreted in many ways, to represent charcters from the alphabet or matmatical symbols or pitch and tone through a sound card.

all 'char' is to the computer is 8 bits 00000000 or 1 byte, it doesn't mean there is a charcter in it that you and I would recognise.

If you do

printf("%s", table_1);

With %s instead of %d to tell printf to interpret table_1 as a string of chars, you will get a load of garbage on screen.

Take the first item in the array 0x08

we know from the 0x it's a hexidecimal number (base 8)

Hexadecimal is base 16 -- octal (base 8) has a leading zero, but not x or X.

Now table_1 is a pointer to the start of the array of numbers in RAM

It's not a pointer, it's an array. But when used in an expression it is implicitly converted to a pointer to the first element.

all 'char' is to the computer is 8 bits 00000000 or 1 byte, it doesn't mean there is a charcter in it that you and I would recognise.

A char is not necessarily 8 bits, that is merely a minimun. But very frequently a byte, the space required to hold a char, is 8 bits.

Drat, just when you think you know something, it turns out you don't know squat.

I did know hexidecimal was base 16, luckily I don't have to deal with it on a daily basis so I guess I'm losing the edge, sob....

This article has been dead for over six months. Start a new discussion instead.