wiring a ceiling fan with 2 wires and a ceiling having 3
The ceiling wiring of red, black, white, and gnd allows separate control of a ceiling fan and a light with ordinary wall switches. One wall switch controls the black (switched hot) and a separate wall switch controls the red (switched hot). The W is a neutral for both and is not switched. If your fan wiring has only a black, a white, and a ground, then cap off (electrical tape or a wire nut) one of the two switched hots (usu you'd cap the red) and connect the black house wire to the black wire of the fan, and the white house wire to the white of the fan.  

The wiring of most fans is a black for the fan, a different color, blue, for the light, and white is a neutral common to both the fan and the light. There should also be either a ground wire or a ground contact screw which is to be connected to the gnd of the house wiring.

It is conceivable that in some newer fans the wiring allows separate control of a fan and a light using only one switched hot wire. And, of course, if the fan had a built in remote receiver (which I have yet to see) the fan and light could be controlled separately with only one hot, and no wall switch. I installed some of the new Hunter fans with remote receiver not built in, and those had black and blue (IIRC) wires for the fan and the light, respectively. A single hot (which could be switched or not) goes to the receiver. Buttons on the remote transmitter switch the fan and light separately.

Decades ago I installed some old Hunter fans without wall switches and we use the pull chains. I recently installed some new type Hunter fans without wall switches but with remotes. I think that the wall switches are useful and I wish I had them, but it is extra work to put in wall switches.