sizeof() didn't produce expected value, but it wasn't wrong
Dan Rosenblatt
dir at obo586.UUCP
Fri May 3 14:38:27 AEST 1985
[]
A function I wrote for some graphics software looked something like:
vecmul(invec,inmat,outvec)
double invec[3],inmat[3][3],outvec[3];
{
int i,j;
double tmpvec[3];
for (i=0;i<3;++i) {
tmpvec[i] = 0.;
for (j=0;j<3;++j)
tmpvec[i] += invec[j] * inmat[i][j];
}
bcopy((char *)outvec,(char *)tmpvec,sizeof(outvec));
}
The calling sequence for bcopy was: (dst,src,size_in_bytes).
The problem is that 'sizeof(outvec)' produced the value 2
instead of what I expected - 24. The reason is (as I kick
myself around the room :-}) is that an array which is a parameter
to a function becomes a pointer to that array. The 2 comes
from the fact that I'm running on a 16-bit 8086 chip. 'nuf said.
Dan Rosenblatt
obo Systems, Inc.
...{ihnp4!denelcor,nbires!gangue}!obo586!dir
More information about the Comp.lang.c
mailing list