2 A C program contains the following declaration static char
2. A C program contains the following declaration. static char *color[6] = {\"red\", \"green\", \"blue\", \"white\", \"black\",
\"yellow\");
a) What is the meaning of color?
b) What is the meaning of (color + 2)?
c) What is the value of *color?
d) What is the value of * (color + 2)?
e) How do color [5] and * (color + 5) differ?
Solution
a)color is an array pointer of strings
b)(color+2) represent the address of 3rd element in an array of pointer of string i.e address of blue
c) *color will have \"red\" value. It represent the first value of an array
d) *(color+2) will have blue value. we are getting value from (color+2) position from an color array or de-referencing value from (color+2) position
e) color[5] and *(color+5) will have same value i.e yellow value
color[5] just return value at index of 5 in an color array
but *(color+5) return value of address of(color+5)
Thanks a lot
![2. A C program contains the following declaration. static char *color[6] = {\ 2. A C program contains the following declaration. static char *color[6] = {\](/WebImages/42/2-a-c-program-contains-the-following-declaration-static-char-1130893-1761604125-0.webp)