trouble with HC-SR04 and 5V DC motor

That code doesn't compile, and there is nothing in that code that hints at motor control.

There are many worked examples for this device.