Is this clean?
I'm trying to translate some C code to Spin/PASM, but I'm having a hard time. It may be me, but I'm finding a lot the code less than intuitive. Is it good practice to have funtcions that operate but do not return anything? Here's an example:
void Vector_Scale(float vectorOut[3],float vectorIn[3], float scale2)
{
for(int c=0; c<3; c++)
{
vectorOut[c]=vectorIn[c]*scale2;
}
}
void Vector_Add(float vectorOut[3],float vectorIn1[3], float vectorIn2[3])
{
for(int c=0; c<3; c++)
{
vectorOut[c]=vectorIn1[c]+vectorIn2[c];
}
}
void Vector_Scale(float vectorOut[3],float vectorIn[3], float scale2)
{
for(int c=0; c<3; c++)
{
vectorOut[c]=vectorIn[c]*scale2;
}
}
void Vector_Add(float vectorOut[3],float vectorIn1[3], float vectorIn2[3])
{
for(int c=0; c<3; c++)
{
vectorOut[c]=vectorIn1[c]+vectorIn2[c];
}
}
Comments
Get a copy of Kernighan and Ritchie if you need to understand the C language.
Agreed with Leon - K&R is a must read for C learning
It sure is... methods can be two basic types, ones that return data and ones that don't. Some languages refer to these as Functions and Subroutines (or just as "Sub" like in VisualBasic.) In most C derived languages, the word "void" indicates the null return value.
It seems you're doing something with 3D graphics objects, correct?
Bill
Thanks.
-Phil
Curious—does K&R even mention void? My copy doesn't.
Just do a google search using C tutorial pdf
@erco
I like your new avatar!