![]() Note that we can't get the data from p because we don't know its type. p is a NULL pointer - do not dereferenceĬhar *c // c is a pointer to a char, usually a single byte Void *p = 0 // p is a pointer to an unknown data type In C, when you cast a pointer to certain type (such as a char * or int *), it tells the computer how to interpret the data at that location. It is up to us (the programmer) to interpret the data at that location. A pointer is a number that references a memory location. Pointers are a key part of programming, especially the C programming language. With me so far? We have 4 bytes, W X Y and Z, each with a different value. If W were to be interpreted as a number, it would be "18" in decimal (by the way, there's nothing saying we have to interpret it as a number - it could be an ASCII character or something else entirely). So, each byte has a value and is made up of 8 bits.įor example, W is an entire byte, 0x12 in hex or 00010010 in binary. Byte ExampleĬonsider a sequence of 4 bytes, named W X Y and Z - I avoided naming them A B C D because they are hex digits, which would be confusing. And there is no agreement on how these sequences should be stored. However, a lot of data needs to be stored using multiple bytes, like integers or floating-point numbers. Well, this is fine for single-byte data, like ASCII text. If computers agree on the order of every byte, what's the problem? The concept of a byte is the same on all machines, and the idea of which byte is first, second, third (Byte 0, Byte 1, Byte 2.) is the same on all machines. If we store and read data one byte at a time, it will work on any computer. ![]() We can use these basic agreements as a building block to exchange data. Bit 0 is the rightmost and the smallest bit 7 is leftmost and largest. So, the binary sequence 00001001 is the decimal number 9.
0 Comments
Leave a Reply. |