September 1998
Intermediate to advanced
848 pages
20h 13m
English
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 ...
Read now
Unlock full access