I apologize if this is a repeated question, but I can’t seem to find the keywords to search for the question that I’m about to ask.
Basically, I have defined myself a struct.
#define max_terms 101
typedef struct{
int row, col, value;
} term;
Now I have three different terms namely, a[max_terms], b[max_terms] and c[max_terms]
I would like to input into the following function’s parameter, so that I can choose to work on which of the three defined arrays
void input(/*parameter here*/){
a[0].row = 0; // want to be able to choose the array to work on instead of just a
}
Thank you for reading!
The easiest approach would be to pass a pointer to the first element of the array to the function.
/* … */
As giorashc notes in the comments, if the arrays don’t all use the same size you’ll want to pass the actual size as an additional parameter.