I am writing a huffman code in C++ and I am now taking data from the files and have encountered a snag. One the first line I have a string of characters that I want to take as a string, which I didn’t find hard at all to do. But then I have to take the next x amount of lines of numbers and take them as unsigned chars so I can use them.
What would I type in if I wanted to extract this form a file?
ILaILbILrILcLd (want to take as a string)
3 (the 3 is the number of #s below it)
89 (want to take these 3 out as unsigned chars
207
88
As Nike tells us, just do it:
It probably won’t accomplish much under the circumstances, but right after the definition of
chars, you could add:chars.reserve(num);to avoid reallocation of thevectors memory.