If you want to break it down into steps:
- Check for the .CSV file you're wanting to open
- If its present, open it
- Connect to your database
- Read each line of the file, splitting the different fields at the commas
- Insert the record(s) into the database, until you hit EOF
- Close the database connection
I've done things like this in Perl, using MySQL as the back end, and can usually do it in just a few lines of code. Haven't played with C in quite a while, though.