In this wiring, a switch and receptacle are in the same box and the switch controls the power to the outlet. The hot wire connects to the bottom terminal on the switch and the top output goes to the receptacle hot terminal. The neutral wire from the source connects directly to the receptacle neutral.
Here a gfci receptacle is added at the end of a row of duplex receptacles for single-location protection. The first outlet is connected to the source and 2-wire cable runs from box to box. All wires are spliced with a pigtail at the devices to pass current from one to the next. The load terminals on the gfci are not used and it does not protect the other receptacles in the circuit.
Run the cable through the clamp and tighten it down. Splice the cable wires to the fan wires using a pigtail splice and a wire nut. Connect the ground to the grounding terminal in the connection box and the ground wire from the fan, if there is one.
This wiring arrangement allows for lowering the lights with a dimmer and controlling the fan with the builtin pull chain. The source is at the ceiling outlet box and 3-wire cable runs from there to the switch box. The neutral from the source is spliced directly to the white wire on the fan kit and the cable, running it through to the switch box.