For the sake of learning C and understanding the difference between Binary Files and Text Files, I\'m attempting to write a string to file as both file types like so:
<
Unix like OS treats both as same.
I'm not sure this is the right answer, but if you want to put a text as hex into a file, try applying \x before the text.e.g. if you are trying to write hello into a file, you're buffer will be:
char *buf = "hello";
If you want to write hex of "hello" into the file, your buffer should be like this
char *buff = "\x68\x65\x6c\x6c\x6f";
Hope it helped