I'll trust @JLBorges for the ciphertext statement. I have no idea about any of that.
However, note in his earlier post:
Any of these would be ok: |
You appeared to try to do all of them, not just one of them.
1 2
|
// Convert message data to a string
temp = { pkt.begin(), pkt.end() } ;
|
Assigns string pkt to temp.
temp.assign( pkt.begin(), pkt.end() ) ;
Assigns string pkt to temp
again. It just replaces the contents with the same contents.
The 3rd example actually has a bug in it. It should probably read
1 2
|
temp.clear() ;
for( char c : pkt ) temp += c ;
|
Explanation:
temp.clear() ;
Erases the contest of temp so that it has a length of 0.
for( char c : pkt) temp += c ;
Takes temp (whatever it contains) and append the contents of pkt to it.
When you tried to use all three methods at the same time, you ran into problems.
If you used the code as is (with the mistake), you would clear temp and then append all the character of temp onto itself. The resultant length of temp would still be 0.
When you didn't clear temp, you ended up appending temp to itself.
DON'T USE ALL THREE METHODS! Just 1. Those were just examples of ways to do it. And if you use the 3rd method, fix the typo first.