OK so I use the following code to get a hash of a file and print it to the terminal. I want to then add this hash to a file with other text based data in it, so I assume I need to convert to ASCII somehow. I must also use the write() system call to do it and not fwrite(). Any ideas?

MD5((unsigned char*) buffer, filesize, md5result);
printf("File: %s Hash: ", filename);
for(j=0; j <MD5_DIGEST_LENGTH; j++) {