A Cape Town magistrate on Wednesday urged a jobless 23-year-old man with four children to use condoms to avoid fathering more children when sentencing him for stealing cheese and hot dog sausages.

"You are only 23, and already have four small children, and it is evident that you have no contact with them if you do not even know their ages," magistrate Grant Engel was quoted by the Sapa news agency as saying.

"You can't even provide for yourself, let alone for your children."

Engel urged Mzawanele Japhta to go to a clinic for free condoms "before you end up with 30 children".

The unemployed man, who lives in a shantytown and could not afford a fine, pleaded guilty to stealing four packs of vienna sausages and cheddar cheese worth 299 rands (41 dollars, 32 euros) from a supermarket.

He was handed a second chance by the magistrate and sentenced to 1,500 rands or 90 days in prison suspended for five years, Sapa reported.