A pointer array is an array in which each element is a pointer
The code than I wrote by myself
#include<stdio.h>
#include<stdlib.h>
int main() {
int n, i = 0;
scanf("%d", &n);
char* StringArray[n];
while (i < n) {
StringArray[i] = malloc(1000);
scanf("%s", StringArray[i]);
i++;
}
for (i = 0; i < n; i++) {
printf("%s\n", StringArray[i]);
}
return 0;
}
Test
Exceptional situation
A static array refers to an array whose size is fixed and cannot be changed during the execution of a program.
If the array is static,and the pointer points to a constant,then there is no need to apply for memory for it.
Just like the following
#include<stdio.h>
int main() {
char* arr[3];
arr[0] = "Hello";
arr[1] = "World";
arr[2] = "Ubuntu";
printf("%s %s %s\n", arr[0], arr[1], arr[2]);
arr[1] = arr[0];
arr[2] = arr[0];
printf("%s %s %s\n", arr[0], arr[1], arr[2]);
return 0;
}