im learning c programing. I want to define a global struct array of. so I would have a pointer to that array that each member of the array is a struct of complex numbers. my goal is to be able to acces to this array by his pointer (*vars) and being able to change/read its members on every function at the main.
Im facing troubles with this issue and im not sure how and where to define each thing. I tried this next code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef struct complext
{
double real;
double img;
} complex;
complex* vars;
int main()
{
int i;
vars = malloc(6 * sizeof(vars));
for (i = 0; i < 6;)
vars[i]->real = 0;
}
Im getting an error when im trying to acces vars[i]. "request for member 'real' im something not a structure or a union. Thanks!