trouble with HC-SR04 and 5V DC motor

No, the compiler already told you the code was wrong.

I'm just confirming it.
Where did you find that code?