Possible Duplicate:
What happens to memory after ‘\0’ in a C string?
Is it possible to make a pointer’s, say, third element NUL (‘\0’), thereafter “erasing” the pointers remaining elements?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you’re talking about C-style strings then yes, kind of:
Note that the characters beyond
s[3]haven’t magically disappeared at this point – it’s just that displaying the string, or passing it to any function that takes a C-style string, results in the string only appearing to contain three characters. You can still do e.g.