I am trying to modularize a function that used to add values to multiple structures in one call. Now I want to do one value addition per call, but I am not sure how to make a less specific argument reference.
func ( [?] *val )
{
}
I am trying to modularize a function that used to add values to multiple structures in one call. Now I want to do one value addition per call, but I am not sure how to make a less specific argument reference.
func ( [?] *val )
{
}
If all structures start with the same "prefix", so you can reach the desired parts at the same offset, then you could make that prefix a struct
of its own and pass a pointer to it -- a "poor man's version of inheritance".
If the desired portions are at different offsets in different structures you can't get away with passing just a pointer to the function (unless via an indirection layer, which can get even more complex) -- simplest may be to pass a pointer and offset, and use address arithmetic to reach the needed part. It's hard to give more specific advice without knowing how your various structures are laid out and what part(s) of them the function needs to reach!