Here\'s what I\'m trying to do:
#include
#include
struct myStruct {
int myVar;
}
struct myStruct myBigList = null;
vo
There are a few errors in your code. Make it:
struct myStruct *myBigList = NULL; /* Pointer, and upper-case NULL in C. */
/* Must accept pointer to pointer to change caller's variable. */
void defineMyList(struct myStruct **myArray)
{
/* Avoid repeating the type name in sizeof. */
*myArray = malloc(10 * sizeof **myArray);
/* Access was wrong, must use member name inside structure. */
(*myArray)[0].myVar = 42;
}
int main()
{
defineMyList(&myBigList);
return 0; /* added missing return */
}
Basically you must use the struct
keyword unless you typedef
it away, and the global variable myBigList
had the wrong type.