On Thu, May 27, 2010 at 02:32:47AM -0400, Chiron Bramberger wrote: > What does the asterisk * in (byte*) mean? I know *p is a pointer, > and I know &q would be an address, but what does it mean when the * > is after something? Actually this is wrong. *p is not a pointer. A pointer is declared by adding the asterisk *after* a type. So unsigned* foo; declares foo as a pointer to an unsigned. This is true for most other stuff, too, so char const a = 3; declares a constant character named a and assignes the value 3. The general rule is that a qualifier (or asterisk) is applied to the type left of it. The only exception for a qualifier is, if is on the left side (so there is no type on the left), then it applies to the type on the right side. A more complex example would be: unsigned const* volatile* bar; which declares a volatile pointer to a pointer to a constant unsigned. > In my textbook there's a second, similar example: > > typedef unsigned char BYTE; > BYTE *p; > p = (BYTE *) 0x1000; /* p contains address 0x1000 */ Using knowledge from above, this means: * We declare the name "BYTE" for the type unsigned char. * Then, we declare a pointer to a BYTE (an unsigned char). * At last, we assign a value to the pointer. This value is the numerical value 0x1000, casted to a pointer to BYTE. Regards Uz -- Ullrich von Bassewitz uz@musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Thu May 27 11:00:12 2010
This archive was generated by hypermail 2.1.8 : 2010-05-27 11:00:13 CEST