+ 4
You are using uninitialized string..
Use
string NewStr=word;
else use append method for adding to string..
+ 2
Manav Roy
at line 8, Frequency = 0 not {}
// use initialized string, Note: make sure that length of NewStr should be equal to the word because you are encoding the word or else fill the NewStr with anything upto the length of string word
string NewStr = word; // NewStr = "00000" ššš
both will work
https://code.sololearn.com/cDjag44DFkqn/?ref=app
+ 2
Your string NewStr{} is zero length so NewStr[i] will access to uninitialized location which will lead undefined behaviour.. Instead try :
NewStr += ')'
Your are reassigning all values of "word" characters, so you need string of length word.length ;
So NewStr = word will define string with desired length....
Hope it clears...