I rarely relate to coding and have some problems understanding how pointers work in combination with arrays (which I myself understand).
I realized that it is possible to create an array of pointers like:
#include <iostream>
using namespace std;
int main() {
int i;
int *pArr[10];
pArr[0]=&i;
return 0;
}
In the tutorial, I found the following code:
#include <iostream>
using namespace std;
int main() {
char *names[4] = {
"name A",
"name B",
"name C",
"name D"
};
for (int i = 0; i < 4; i++) {
cout << names[i] << endl;
}
return 0;
}
Why is it that I can assign multiple characters or say a string like "name A" to a pointer that should point to a char.
Do I A:
Only be able to assign a char address to each of these 4 pointers that I created.
And B:
Only be able to assign a pointer to one letter (a char) to each.
I hope someone can help to some extent eliminate my confusion.