views:

87

answers:

1

I have a function which accepts a pointer to a struct and sets a member of that struct to a specific value. However, after that assignment code is executed, and my program exits without showing any errors.

void swn_addClassToInstance(struct instanceR *instance)
{
 instance->classCount = 0;
 //nothing below here will run
}

I'm new to C, and any help would be appreciated.

+3  A: 

Most probable cause is that instance is NULL or not initialized, thus causing an access violation. It would be help if you show the code where you allocate and initialize the memory for the struct instance points to.

Franci Penov
It turns out my struct wasn't being assigned properly. Thanks.
Tim Cooper