Explanation is a bit long so please bear with me, solution is short :lol:
We got an assigngment from uni to create word dictionary program to read an external file where each line consist of WORD and DEFINITION separated by empty space. If some word exists more than once add other definitions append. Please use static hash table and sort datat in alphabetic order:evil:
Fine we will do it. :mrgreen:
Using getline we get word and then definition plus this automaticaly delete '\0' character and next function insert them in hash table. As long word does not repeat everything it's fine. But if program find that word already exists in table we should join definitions as

1st_def = 1st_def + 2nd_def

however if you do that table will strangly get mess up. To prevent this behaviour you have to do following

1st_def = 1st_def + "\n" + 2nd_def

Took some time to find out.
Reading is finish, data in hash table we sort them now is time export them.
Format :


what we get is of course


OK, we have to delete new line character in order to get proper out put. We store definition in temporary variable, then search this variable for new line character, if found replace it with one empty space ( " " ). Well search and replacement work perfect but when outputing everything get mess up. AGAIN!!!

Can anybody provide me with explanation what is happening over there and how should I stop this bad manners of my program?