The USGA defines a stroke as “the forward movement of the club made with the intention of striking at and moving the ball, but if a player checks his downswing voluntarily before the clubhead reaches the ball he has not made a stroke.”
This means you do not actually have to touch the ball for it to make a stroke. Under this definition a “whiff” would count as a stroke. This also means that in the process of your downswing you can “abort” the swing by intentionally missing the ball. It will not count as a stroke because you did not intend to strike the ball nor did you strike the ball. If you strike the ball, regardless of your intentions, it counts as a stroke.
The next time you count up your score make sure to count those “whiffs”.