The problem with function pointers is that in toy cases they seem a bit pointless. You only realize how useful they are once you get into more complex stuff.

In generic terms:
1) Define a function pointer func that matches the signatures of functions f and g.
2) Read input. Depending on input, assign either f or g to func.
3) Call whichever function func points to by dereferencing func.

Let's say you have 10 places where f or g need to be called. The "normal" way, you'd need 10 if statements. With a function pointer, you only need 1 (to set the pointer).