Vim Open TXT file see ^@ character

Source: Internet
Author: User

' + ' 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.