You are writing binary data to a file and then opening it with a text editor. The result is UNDEFINED. When you see that word "UNDEFINED" in documentation, pay attention. It is your responsibility to not do things like that. A text editor is for opening text files, which means strings. The way to write an int into a text file is to do something like:
char str[BIGNUMBER];
sprintf(str, "%d", d[0]);
fwrite...
That is probably not what you wanted but it is the only way to get a Notepad compatible text file. What you probably want to do is to find a binary file editor that can open, display and edit binary files. Personally I just use vim with the -b option, even on Windows.