Solution for Exercise 18-11
#include <stdio.h> int main() { char a,b,c; char *p; a = 'A'; b = 'B'; c = 'C'; printf("Know your "); p = &a; /* initialize */ putchar(*p); /* use */ p = &b; /* initialize */ putchar(*p); /* use */ p = &c; /* initialize */ putchar(*p); /* use */ printf("s\n"); return(0); }
Output
Know your ABCs
Notes
* Line 8 isn't a trick. I'm just taking advantage of the fact that the compiler ignores white space. So rather than separate each statement with an Enter key press, I used a space.
Copyright © 1997-2024 by QPBC.
All rights reserved