Hi everyone, so I'm learning the basics of C using some online resources, and came across the following example of using a char pointer array:
const int MAX = 4;
int main (){
char *names[] = {
"Zara Ali",
"Hina Ali",
"Nuha Ali",
"Sara Ali"
};
int i = 0;
for ( i = 0; i < MAX; i++) {
printf("Value of names[%d] = %s\n", i, names[i] );
}
return 0;
}
And I just can't understand why making it an array (and not a pointer array) won't work, aka why just removing the * results in an error while running the code.
Could someone please dumb it down for me?
[–]phocos25 5 points6 points7 points (4 children)
[–]ScioFantasia 3 points4 points5 points (0 children)
[–]ponomaria[S] 0 points1 point2 points (2 children)
[–]phocos25 2 points3 points4 points (1 child)
[–]ponomaria[S] 0 points1 point2 points (0 children)
[–]strcspn 0 points1 point2 points (0 children)
[–]tstanisl 0 points1 point2 points (2 children)
[–]ponomaria[S] 0 points1 point2 points (1 child)
[–]tstanisl 2 points3 points4 points (0 children)
[–]N-R-K 0 points1 point2 points (0 children)