Why i am unable to sort char array?


I want to sort b[l/2]
this code is sorting a[l/2] perfectly but having problem in array b
how to fix it ??

You have declared array of size l/2 and you are accessing l-1.how can that be possible? to fix it just increase size of array from l/2 to l

hey I think you don’t know about the power of standard template library in c++ you make use sort() function that will simply sort your array in ascending order you just need to pass two arguments. start index which you can say your array name as name of array represents the start index and the size of your array.
ex,
c++ 14 and c++
refer to the link : https://ide.codingblocks.com/s/162199

hey! i think u need to learn baics for now (just suggetion) because if u are unaware of ascii table or these functions then u should study these first.https://codeforces.com/blog/entry/23054 this may help in your learning process.
happy coding:)

1 Like