South Africa secured their first win of the Cricket World Cup at the fifth attempt with a nine-wicket hammering of Afghanistan.