Hi,im trying to write a c++ code for aplhabetical sorting....
I succeeded partially...But the code wont work if the number of characters goes beyond 6.
I assign a number for every word in the following way and sort the words by sorting the numbers assigned to the corresponding words.
ex: worddd = 23*27^5 + 14*27^4 + 18*27^3 + 4*27^2 + 4*27 + 4
(w is 23rd aplabet,o is 14th,r is 18 th and d is 4th )
anything beyond 6 characters would exceed the range of int.
Reinventing the wheel can sometimes be very helpful as a learning exercise, though I don't really think this is the case.
Anyway, if you want to do it in a more low level fashion, you can compare the chars themselves with relational operators. No standard library involved.
You don't need to convert the characters into one big integer. Each individual character is a number so you need to visit every character of both strings and compare them until you get a mismatch.