What does '\0' mean?

后端 未结 6 1701
梦如初夏
梦如初夏 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:41

    \0 is the NULL character, you can find it in your ASCII table, it has the value 0.

    It is used to determinate the end of C-style strings.

    However, C++ class std::string stores its size as an integer, and thus does not rely on it.

提交回复
热议问题