I'm a little confused about how to use const. I have a struct person and I have an array of pointers to person structs. I want to have a showgroup() method that takes an array of pointers to person, prints the person structs and makes sure the pointers to struct are not modified nor are the structs themselves modified. Am I doing this right?
Code:
struct person {
char fname[40];
char lname[40];
};
// Array of const pointers to const person struct's?
void showgroup(const struct person * const group[], int n);
...
struct person group[10];
struct person *pgroup[10];
for (x = 0; x < 10; x++)
pgroup[x] = &group[x];
showgroup(pgroup, n);