What does '\0' mean?

后端 未结 6 1706
梦如初夏
梦如初夏 2020-12-29 05:55

I can\'t understand what the \'\\0\' in the two different place mean in the following code:

string x = \"hhhdef\\n\";
cout << x << endl;
x[3]=\'\         


        
6条回答
  •  渐次进展
    2020-12-29 06:35

    The \0 is basically a null terminator which is used in C to terminate the end of string character , in simple words its value is null in characters basically gives the compiler indication that this is the end of the String Character Let me give you example - As we write printf("Hello World"); /* Hello World\0 here we can clearly see \0 is acting as null ,tough printinting the String in comments would give the same output .

提交回复
热议问题