On Linux, the ip link set down dev ethX does nothing more or less what you want. I would suggest calling this program to do your job if you are on this platform.
If you want to do it yourself, the C api is not an easy thing to do. You can dive into the iproute source to find out what it does.
Check out @ user611775's answer for a great example of how to do this in C.
If you are on a different Unix, the answer will probably be different for each particular taste.
source share