Here is the problem,
void readStructs(tMystruct *theVar)
{
scanf("%d",theVar.id); //<------problem
scanf("%f",theVar.length); //<------problem
}
You should access Structure pointer member using ->
operator and also you’re missing &
that will eventually cause a segmentation fault.
Here is the modified code,
void readStructs(tMystruct *theVar)
{
scanf("%d",&theVar->id);
scanf("%f",&theVar->length);
}
solved How to pass structure by reference in C?