One possibility is to open the ASCII file to read with fopen ("asciifilename", "r"); and to open the binary file for writing using fopen ("binaryfilename", "wb"); Also have a look at the functions fread (), fwrite, and fclose() in the ANSI C library.The idea would be to read the data as text file, and then write the data in binary format. You do not need to convert anything on your own.
You may also want to have a look here
If your prefer, you can also use the functions ScanFile / FmtFile from the Formatting and I/O Library...