I l @ ve RuBoard |
The printout is this:
D D O O L L T T
The array ref has an external storage class; it is a global variable with external linkage.
The array name ref points to the first element of the array, the character D . The expression ref + 1 points to the second element, the character O . The construction ++ref is not a valid C expression; ref is a constant, not a variable.
ptr points to the first element, and ptr + 2 points to the third element, which would be the first element of the second row.
12 and 16
12 and 14 (just the 12 goes in the first row because of the braces)
ptr points to the first row and ptr+1 points to the second row; *ptr points to the first element in the first row, and *(ptr + 1) points to the first element of the second row.
12 and 16
12 and 14 (just the 12 goes in the first row because of the braces)
&grid[22][56]
&grid[22][0] or grid[22]
(The latter is the name of a one-dimensional array of 100 elements, hence the address of its first element, which is the element grid[22][0] .)
&grid[0][0] or grid[0] or (int *) grid
(Here grid[0] is the address of the int element grid[0][0] , and grid is the address of the 100-element array grid[0] . The two addresses have the same numeric value but different types; the typecast makes the types the same.)
int digits[10];
float rates[6];
int mat[3][5];
char (*pstr)[20];
Note
char *pstr[20]; is incorrect. This would make pstr an array of pointers instead of a pointer to an array. In particular, pstr would point to a single char , the first member of the array; pstr + 1 would point to the next byte. With the correct declaration, pstr is a variable rather than an array name , and pstr + 1 points 20 bytes beyond the initial byte.
char * psa[20]; . Note that the [] have higher precedence than * , so in the absence of parentheses, the array descriptor is applied first, then the pointer descriptor. Hence, this declaration is the same as char *(psa[20]); .
int sextet[6] = {1, 2, 4, 8, 16, 32};
sextet[2]
0 through 9
rootbeer[2] = value;
Valid
scanf("%f", &rootbeer );
Invalid; rootbeer is not a float .
rootbeer = value;
Invalid; rootbeer is not a float .
printf("%f", rootbeer);
Invalid; rootbeer is not a float .
things[4][4] = rootbeer[3];
Valid
things[5] = rootbeer;
Invalid; can't assign arrays.
pf = value;
Invalid; value is not an address.
pf = rootbeer;
Valid
I l @ ve RuBoard |