I am NOT a Unix guru, I am a waiter. And I never went to computer school, I figured it out as I went. And I never learned C, I read a few books from O'Reilly on C++, Perl, PHP, Korn shell. I do my scripting using text editor, no auto-generating sw.
What you are asking for, I can do it, on a Cisco router.
So, I am not the best resource for you.
But, if I were you, I would download Nmap from
http://download.insecure.org/nmap/dist/nmap-4.53.tgz
untar it, look through the .c and .h files, use them as an example.
Good luck doing your homework.