line 13 : index should be compared with str.length line 14: should be str[index] = '\0'; i.e if the "index" calculated is less than the original string "str" then that means, str has extra spaces so to avoid those extra spaces in the final result we add null char at "index" position.
@thohuynh437 Жыл бұрын
Thanks for explanation. I think the author just copy code in the book. I'm reading the 6th edition of the book and was confused by those 2 lines
@dinosaurperson23494 жыл бұрын
I cant understand why its str[index-1] rather than just str[index] which would make the others str[index-1] and str[index -2]
@neghatnazir16684 жыл бұрын
thanks again :), can you pls tell me what is true length here? length of given string with all the whitespaces in between and end ? or length of string from from 0 to last char?
@pawansnair9974 жыл бұрын
"Mr John Smith " True length for this is 13
@neghatnazir16684 жыл бұрын
@@pawansnair997 thanks got it! :)
@Explorebyrajat0 Жыл бұрын
Done mil gaya
@raz4783 жыл бұрын
I think, instead of str[trueLength] = '\0' it should be str[index] = '/0'. NO?
@steved.10912 жыл бұрын
This line is totally unnecessary in Java, seems like he just copy-pasted the solution from the book. And for C/C++ it should be str[index]
@loveki5369 Жыл бұрын
Bhai apney concept shi se nhi smjha, ye aesey nhi hoga, apney code voh gayle lokmam mackdowell vali book se same to same teep diya hai