Q:

When I write a file in mode "wb", what will happens?

When I write "asklfj123" into a file in mode "wb", then I open it in vim,
why I can still see  asklfj ?but I can not see 123 in vim. I mean that when I write it in mode "wb", the program will not convert it into ASCII code, but the editor will open it with ASCII code, then it should be garbage values in text editor, isn't it? then why I can still see them?  

A:

Binary mode means "don't translate anything". 
In "text" mode (that is "not binary mode"), on some systems, the representation of for example newlines is different between the OS's file representation and the standard '\n' that C uses for newline representation. 
In some systems there are also special characters to represent end of file. When in text mode, these characters are translated and understood to mean newline and end of file, respectively. 
Now, writing text in "binary" mode will work just fine, and I would suspect your problem is something else - without code, it's impossible to answer what. The mention of vim also makes me think that you are using Linux or some other Unix-based system, where newline is indeed the same as '\n', so no translation is done in these systems. 
Edit:
Given the code, it's typical "undefined behaviour", because:
char test[30] = "adadsf123";
...
fwrite(test, sizeof(double), 6, fp);

The arguments for fwrite is the data to be written, the size of each member, and the number of items, and finally the file object to write it to. 
In this case, a string of 30 bytes is given as input, then sizeof(double) as the size of each item, and 6 items. Since sizeof(double) is more than 30, some random garbage is being output. What that random garbage is, is depending on what is stored i the memory after the test variable. In the code posted, that appears to be the fp variable. It's hard to say exactly what the fp's value will be. But fwrite is doing exactly what it has been told, writing binary data to a binary file. ASCII characters, in "binary" will still appear the same, the binary code of 'A' is 01000001, and that will appear, if interpreted as ASCII shows as 'A' - and VIM and putc will interpret that as ASCII.

