It sounds like from your questions that you are unclear on the fundamental rules for pointers. Many people who post questions in the C tag are unclear on this. Basically:
- A storage location can hold a value of a particular type.
- If you apply the
& operator to a storage location you get a pointer to the associated type.
- A pointer is a value.
- If you apply the
* operator to a pointer you get a storage location.
Technically a storage location is called an "lvalue" but that seems needlessly jargonish for the beginner.
So let's take a look:
int *const firstElementNum = myArray[0].structNum;
That's not right. structNum is a storage location that contains a value of type int. But to assign to firstElementNum we want an expression of type "pointer to int".
Try again:
int *const firstElementNum = &myArray[0].structNum;
That's better. structNum is a storage location of type int. The & operator gives you a pointer to int. That's a value that can be stored in storage location firstElementNum.
firstElementNum = 5;
This is doubly wrong; first, you're trying to write to a const storage location, and second, this is trying to assign a value of type int to a storage location of type "pointer to int".
*firstElementNum = 5;
This is right. firstElementNum is a storage location that contains a pointer to int. Applying * to that value makes a storage location of type int, which is what you need.