Collision between circles and squares

I just recently starting doing collision detection. I understand collision between two squares in SDL just fine. However, I am a little lost as how to program collision detection between a circle and a square...

How would I go about doing it? The way I figure it, test every side of the square to see if the distance between the side of the square and the radius of the circle is larger or smaller. But the thing is I don't know to code that thought.

Any help is greatly appreciated. Thanks in advance.