If you use length() method, then it would return 4. But if you use sizeof() method, then it would return 4+1(for null character)=5.
length()
sizeof()
The strlen() function calculates the length of the string by counting the number of all characters until it reaches the null terminator ('\0'). So the length of this string “GATE” is 4.
strlen()
64.3k questions
77.9k answers
244k comments
80.0k users