Review Questions
What will this program print?
#include <stdio.h> char ref[] = { 'D', 'O', 'L', 'T'}; int main(void) { char *ptr; int index; for (index = 0, ptr = ref; index < 4; index++, ptr++) printf("%c %c\n", ref[index], *ptr); return 0; }
In Question 1, what storage class is ref?
In Question 1, ref is the address of what? What about ref + 1? What does ++ref point to?
What is the value of *ptr and of *(ptr + 2) in each case?
int *ptr; int torf[2][2] = {12, 14, 16}; ptr = torf[0];
int * ptr; int fort[2][2] = { {12}, {14,16} }; ptr = fort[0];
What is the value of **ptr and of **(ptr + 1) in each case?
int (*ptr)[2]; int torf[2][2] = {12, 14, 16}; ptr = torf;
int (*ptr)[2]; int fort[2][2] = { {12}, {14,16} }; ptr = fort;
Suppose you have the ...
Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.