Okay, so I've been making a little code to teach myself about compression. Essentially, it compresses a strand of DNA (series of A, T, C, and G) and then assigns a value of 00, 01, 10, or 11 respectively. However, it seems like the final output, aka the cmpr string is blank. In my code, I have it cout both the i variable and the current status of the cmpr string just so i can see where I am going wrong, and the i variable seems fine, but the cmpr never changes from a blank line. I know the code is super messy and probably quite inefficient, but I just typed it up pretty quick. Hope its readable. Thanks in advance!
I see, so cmpr is specific to main. And to fix that, would i specify cmpr in the codeDown prototype? And yes, I know the program itself takes up much more data, I'm just trying to understand the idea of compression, like in the Huffman algorithm.
And to fix that, would i specify cmpr in the codeDown prototype?
You could take a string by reference in codeDown, but you wouldn't be specifying cmpr in the prototype - you would feed it to the function at the time that you call it. Even then, there are other problems with your code. You are encoding the "index" i which I hesitate to call in index, because it doesn't index the first character of the string and does index the nul-character ending it.