' + ' characters are invisible characters, the Vim editor uses the ' ^@ ' character to display the ' \ S ' character.
Look at the following code:
#include <stdio.h> #include <stdlib.h>int main ( ) { char buf[] = "hello world!"; file * fp = null; size_t ret = 0; fp = fopen ("./test.txt ", " a "); if (fp == null) { printf ("fopen error!\n"); exit ( -1); } ret = fwrite (Buf, sizeof (char), sizeof (BUF), &NBSP;FP); printf ("ret = %zd\n", ret); fclose (FP); exit (0);}
After the program executes, a test.txt text file is generated in the current directory. Use the Vim editor to open the content as follows:
Hello world!^@
The problem appears in the following code:
ret = fwrite (buf, sizeof (char), sizeof (BUF), FP);
This statement puts ' + ' characters are written to the Test.txt text file.
Change this statement to the following form:
ret = fwrite (buf, sizeof (char), strlen (BUF), FP); Need <string.h>
The resulting text file will no longer contain the ' \ S ' character.
This article is from the "Drifting Away" blog, make sure to keep this source http://shuying.blog.51cto.com/9460406/1914275
Vim Open TXT file see ^@ character