To compare C style strings you would use strcmp(), or a related function, rather than the < or the > or the == operator like you would for numerical values.
If you are alllowed to use STL string objects, then the STL string class has the <, > and == operators overloaded for you.
Lerner
Nearly a Posting Maven
2,406 posts since Jul 2005
Reputation Points: 739
Solved Threads: 405
Skill Endorsements: 8
No. You need to compare items to be sorted in Bubble Sort. You can't use the math comparison operators to compare C style strings. You need to use strcmp(), or related functions. You use C style strings in the program you wrote. Because of the cumbersome nature of strcmp() you could potentially streamline things somewhat if you were allowed to use STL string objects instead of C styl strings, as the STL class has the math operators overloaded for you so you don't need to use the cumbersome strcmp(), or related, function(s).
Lerner
Nearly a Posting Maven
2,406 posts since Jul 2005
Reputation Points: 739
Solved Threads: 405
Skill Endorsements: 8
Not too bad. However, your boundaries in the for loops are off a bit. Since you will be comparing elements at i and i + i you want in to be no larger than the next to last element in the array. If there are 10 elements the last valid element is 9 so you don't want i to be more than eight. I general if array has n elements then you want i to be less than n - 1. j however, can be the last element the array or less than n if there are n elements in the array.
In addition, where did strbuffer come from?
Also, remember to use code tags when posting code to this board!
Lerner
Nearly a Posting Maven
2,406 posts since Jul 2005
Reputation Points: 739
Solved Threads: 405
Skill Endorsements: 8
>>Students are NOT allowed to post on forums,
Where did you get that idea? There are guidelines to be followed to ensure a learning process, particularly when the post has to do with homework, but we are all students as we all have something to learn.
Lerner
Nearly a Posting Maven
2,406 posts since Jul 2005
Reputation Points: 739
Solved Threads: 405
Skill Endorsements: 8