PRO
睿宏
asked

Expert
Udayan Shakya answered
Hello there! It's natural to be confused about the sizeof operator in C, and whether it includes the null terminator as well.
To answer your question: no, we don't need to write sizeof(name) + 1 because sizeof measures the full size of the variable (in bytes), which includes the null terminator as well.
Hope that helps! Contact us again if you have further questions.
C
This question was asked as part of the Learn C Programming course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer