mixing pointers and arrays
Stuart Friedberg
stuart at rochester.UUCP
Wed Aug 17 11:46:27 AEST 1983
I recently ran afoul of the difference in treatment of structures and
arrays. I had an array which was passed to an image processing program
to be filled with the locations of all the boundary points of an image.
The call was BoundaryPoints(Image, Bounds). (Image and Bounds both arrays).
I then decided to have BoundaryPoints calculate a few related values like
centroid and "mass" of the interesting part of the image. I changed Bounds
to be a struct including the earlier array and adding variables for the
new info. I updated all the references to Bounds, but left the call alone.
Surprise, surprise! It all compiled, but previously working code crashes.
Well, it rapidly became clear that the structure was being passed by value,
not reference, but I did think that it was an unnecessary "gotcha".
Shades of the uniform reference problem!!!
Stu Friedberg
More information about the Comp.lang.c
mailing list