1 votes 1 votes char st[] = {‘G’,’A’,’T’,’E’,’\0’}; then string ka length 4 hoga ya 5 with null character? Programming in C strings + – Durgesh_7979 asked Jun 7, 2023 • retagged Sep 17, 2023 by Hira Thakur Durgesh_7979 439 views answer comment Share Follow See 1 comment See all 1 1 comment reply rhl commented Jun 7, 2023 reply Follow Share you are asking what will be output if we pass it to sizeof() operator? coz i believe sizeof() does count \0 null character. so it will return $5$ 0 votes 0 votes Please log in or register to add a comment.
Best answer 4 votes 4 votes 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. Gladingi answered Jun 8, 2023 • edited Jun 16, 2023 by Gladingi Gladingi comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes 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. vaishu_0702 answered Jun 27, 2023 vaishu_0702 comment Share Follow See all 0 reply Please log in or register to add a comment.