LearnFrenzy
Sign in Take a free test

C Library Functions · Library Functions MCQ · Question 6

Does strlen() count the null terminator? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

What is strlen("hello")?

  • A 6
  • B 5 Correct
  • C 4
  • D It depends on the array size
Correct Answer: Option B

strlen counts characters before '\0'. Storing the string needs strlen + 1 bytes; sizeof "hello" is 6.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links