I have pointers like that. I don't know if I did this properly. I don't know how to allocate memory for them. Maybe the computer allocates memory automatically?
char *d = "Array1";
char *d1 = "Array2";
char *e = "Sum array";
The compiler will allocate an array of char with static storage duration for each string literal and initialize the variables to point to the first character of those char arrays.
Is it possible to make an array of pointers like this:
char *names[] = {"Array1","Array2","Sum array"}
Yes (although the declaration requires a semicolon), the compiler will set the length of the names array to 3 automatically to match the number of initializers since the length has not been specified explicitly.
As before, the compiler will allocate an array of char with static storage duration for each string literal. The compiler will initialize each element of the names array to point to the first character of those char arrays.
Since the contents of these string literals match those used to initialize the d, d1 and e variable, the compiler might overlap the storage for the identical string literals. This is OK because C code must not modify the storage occupied by these string literals.
If names[] has automatic storage duration (in a function), you could declare and initialize it as follows, assuming d, d1, and e are already pointing to the correct string literals:
char *names[] = {d, d1, e};
Then the elements of names[] will be pointing to the exact same string literal char array storage as d, d1 and e.
And how to use this pointers when I call a function?
I usually use (the second argument is my pointer):
writeArray(wc, e, n, arr2);
So when I use an array of pointers it will be something like that?
writeArray(wc, name[2], n, arr2);
Yes, exactly like that.