1 votes 1 votes DOUBT: suppose a memory space of 16B is given and it is asked that what is the maximum length of string it can store. then do we have to consider the space taken by the “\0” also? OR just the string length? Programming in C programming strings + – Pranavpurkar asked Sep 27, 2022 retagged Sep 28, 2022 by makhdoom ghaya Pranavpurkar 329 views answer comment Share Follow See 1 comment See all 1 1 comment reply Nisha Bharti commented Sep 27, 2022 reply Follow Share So the ans is only string length, but it is for maximum length of string. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes I think yes because it differentiate the two strings like iitbiitd here is two string so we have to take extra space to differentiate between them that is called null “\0” iitb\0iitd\0 ………….. yes it differentiate two strings but null terminating character does not take any space. and null terminating character also take space. Nisha Bharti answered Sep 27, 2022 edited Sep 27, 2022 by Nisha Bharti Nisha Bharti comment Share Follow See all 6 Comments See all 6 6 Comments reply Abhrajyoti00 commented Sep 27, 2022 reply Follow Share "\0" (null character) does take space of $1$ Byte. @Nisha Bharti count the number of letters, its $12$ without the null character and $13$ with the null 1 votes 1 votes Nisha Bharti commented Sep 27, 2022 reply Follow Share @Abhrajyoti00 sorry it take space i already said but after adding screenshot did not know what i said😅 1 votes 1 votes Pranavpurkar commented Sep 27, 2022 reply Follow Share @Nisha Bharti so in greetings[] you have given each element of array specifically . and in greetings2[] a string is given which is then stored in an array with a NULL string. is this the correct difference between these two? 0 votes 0 votes Pranavpurkar commented Sep 27, 2022 reply Follow Share so for 16B it can store a maximum 15B length of string right? and 1B for NULL . 0 votes 0 votes Nisha Bharti commented Sep 27, 2022 reply Follow Share @Abhrajyoti00 no difference. 0 votes 0 votes Nisha Bharti commented Sep 27, 2022 reply Follow Share @Abhrajyoti00 no actually it can store 16B of maximum length of string. now after 6 byte it get overflow. 0 votes 0 votes Please log in or register to add a comment.