I'm writing a homework assignment that requires me to convert various strings to ints and back. From the FAQ I'm using sprint and snprintf(as we're supposed to show various ways of doing this) to convert an int to a string. Everything works great until I enter a "binary" number in the form of int i = 0011, which sprintf and snprintf convert to char[] = 11.

I've racked my brain and searched the forums for how to get around the automatic removal of the leading 0's to no avail, so any suggestions would be greatly appreciated.

Thanks.