Kris Roofe Kris Roofe - 3 months ago 8
C Question

Why *strptr = 0 truncate the string?(C)

Why *strptr = 0 truncate the string?(C)

Why the ascii value 30 of 0 become 0 of null?

Seb Seb
Answer

More precisely, there are three lexical elements that contain a zero character: 0 (unquoted), '0' (quoted, typically (but not always) equal to 48 or 0x30 unquoted) and '\0' (equal to 0, but in character notation).

The question is talking about two distinct values...'0' != '\0'. Forget about 30, 48, etc. Just remember '0' and '\0' are different characters, and '\0' is a string terminator that has a value of 0...

I think you meant to use '0' (emphasis on the quotation marks).