Have you never studied Pythagoras' theorem? He states that the Quare of the length of the hypotenuse is equal to the sum of the squares of the other two side. Extending this into 3D space, the distance is equal to the sum of the squares of the other
three sides. The sides are just the difference.
So:
float height,width,depth,distance;
height = abs(obj1.y-obj2.y);
width = abs(obj1.x-obj2.x);
depth = abs(obj1.z-obj2.z);
distance = sqrt(height*height + width*width + depth*depth);
I believe to use abs and sqrt you must include math.h