Hello,
I have a structure and an multidimensional array of that structure. How can I access (read and write) that array's element's fields (without defining it as a global variable) inside a function when the array is declared in main() ?
Here's how I tried it (but failed):
Code:
#include <stdio.h>
typedef struct {
double xy;
char *message;
} twin;
void print(twin *table, char *m, int i)
{
(*table[i][1]).message != m ? <----- error: subscripted value is neither array nor pointer
printf("\nX = %f Y = %s", *table[i][0].xy, *table[i][1].message): <----- same here (twice)
printf("\nX = %f Y = %f", *table[i][0].xy, *table[i][1].xy); <----- same here (twice)
return;
}
int main()
{
int i, n;
double x, a, h;
char v[] = "empty";
...
twin table[n-1][1];
...
print(&table, &v, 1);
return 0;
}
Best wishes,
Desmond5