With your help here in this site (the question is here), I've created a struct pointer as following:
struct myStruct {
char charVar;
int intVar;
};
int indexnum = 1;
struct myStruct *p = NULL;
p = malloc(sizeof *p);
p[indexnum].member = x;
index++;
everytime I add a new struct, I increase 'indexnum' so I give different names for each struct.
"mystruct" is global, but the declaration "struct myStruct *p" is in the main function.
the problem is, I cannot reach that p structs from other functions. I just couldn't figure out how to.
The following code is just one of the many trials,
void func1 (char str1, int index, int num1){
int i=0;
struct myStruct *p = NULL;
p[i].charVar="adadsasd";
When the debugger reaches this last line, I get this error: Unhandled exception at ...... Access violation writing location
What should I do?