Solution for Exercise 18-9
ex1809
#include <stdio.h> int main() { char lead; char *sidekick; lead = 'A'; /* initialize char variable */ sidekick = &lead; /* initialize pointer - IMPORTANT! */ printf("About variable 'lead':\n"); printf("Size\t\t%u\n",sizeof(lead)); printf("Contents\t%c\n",lead); printf("Location\t%p\n",&lead); printf("And variable 'sidekick':\n"); printf("Contents\t%p\n",sidekick); return(0); }
Notes
* For a Macintosh, or some other Unix variant, change the conversion character used in printf() at Line 12 to %ld
.
* The memory addresses you see in the program's output may not have the leading 0x
prefix as shown in the book.
Copyright © 1997-2024 by QPBC.
All rights reserved