strtol will take a string with a number in it and convert it to a long int. You would set the base argument to 8 in your case. It's function prototype looks as follows:
long int strtol(const char *nptr, char **endptr, int base);
Reading the man page on this (man strtol) will tell you more. The manual pages are also available on-line at numerous different places.
As far as converting it to binary, I'll leave that to you, this sounds suspiciously like a school project