c/c++中memset(str, 0, sizeof(str))
与memset(str, '/0', sizeof(str))
与
memset(str, '\0', sizeof(str))有什么区别呢?
黄舟2017-04-17 15:18:33
''
refers to escaping a decimal value of 0 into an ascii character, so the ascii code value of ''
is 0, so there is no difference. Also memset(str, '/0', sizeof(str))
may not be correct.
It is customary to use ''
to represent the end of a string. In terms of readability, it is more readable than using 0