I have been working on an S-function for matlab in c.But the following code is crashing.My basics in c is very poor 🙂
//
static double a=0;
//
static void mdlOutputs(SimStruct *S, int_T tid)
{
const real_T *u = ssGetInputPortRealSignal(S,0);
a=*u; //this line creates the problem
}
//
The documentation doesn’t say that the return can be anything else than a pointer, but as commenters have pointed out you should check it for being
NULLbefore de-referencing.