February 6th, 2013, 08:29 AM
Re: Shell sort won't work in this program (the algorithm itself works just fine)
Just in addition -- you wound up using char arrays to represent strings -- once you did that, then you need to know how to use char arrays, and obviously you didn't know how to do this.
Originally Posted by devilsummer
You cannot compare char arrays (or any arrays) using the logical operators <, >, <=, >=, etc. You have to write a loop or call a function that loops over all the elements and determines which item is different in each array. In the case of char arrays, the function is strcmp.
If you had instead used a std::string, then all of that code you had would have worked, since <, >, <=, >=, etc. are all supported by std::string. The trick is that if you're writing this kind of code, use types that are supported by the operators used in such code.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.