Yup I noticed this just before I handed it in thankfullyI missed a key step, first do the same check I described but to check if you can win, if so do that. Then check to see if they can win and block, otherwise random.
Start with something real simple. Take it slow and make sure you have old versions you can go back to, so you can test improvements. Start stupidly simple, you have a "Have I won/lost" function and so make a "Place random" function. Take it from there. Try a "Am I about to win/lose" function. Then think about the weighted system talked about in that link.
From there you can get AI systems to play against each other which is always fun!
EDIT: Just looked at your code, I think there is a bug in the check_win function. Your third if statement reads:
if (board[0][0] == board[1][2] && board[0][2] == board[2][2] && board[0][2] != ' ')
and it should be:
if (board[0][2] == board[1][2] && board[0][2] == board[2][2] && board[0][2] != ' ')