Hi, I'm working on some questions for homework and I have a small idea what the answers may be. Can anyone look my answers over and help me out maybe explaining why they may be wrong or right?
Question 1: answer "b"
Here is a diagram of memory:
Which declaration would generate this ?
f: [[char*][int]] [[char*][int]] [[char*][int]] // <- assume 3 items contiguous in mem
typedef struct
{
char *name;
int ssn;
} Foo;
a) Foo f[3];
B) Foo *f[3];
c) Foo **f[3];
Question 2: answer "a"
Assume this declaration: int * arr;
Which diagram best describes memory allocation ? (CIRCLE ANSWER)
a) arr: [int*]
B) arr: [int*] --> [NULL]
c) arr: [int] --> [NULL]
d) arr: [NULL]
Question 3: answer "a"
Assume this declaration: int ** arr;
Which diagram best describes memory allocation ? (CIRCLE ANSWER)
a) arr: [int**]
B) arr: [int*] --> [int*]
c) arr: [int*] --> [int]
d) arr: [NULL]
Question 4: answer "b"
Assume this declaration: int * arr[5];
Which diagram best describes memory allocation ? (CIRCLE ANSWER)
a) arr: [0][0][0][0][0]
B) arr: [NULL][NULL][NULL][NULL][NULL]
c) arr: [int*][int*][int*][int*][int*]
d) arr: [5]