C++ strings, append, and newlines

by Samm Bennett
While reading in a file using the string append method, I noted that my string was actually being replaced instead of appended to! Apparently, attempting to append a string with another string that ends in a carriage return results in this behavior. Of course, getting rid of the carriage return obtains the desired behavior.

So, the following code: line.append(tmp_line.substr(0, tmp_line.size())); replaces line with tmp_line; while line.append(tmp_line.substr(0, tmp_line.size() - 1)); appends tmp_line to line. Now I just wonder if this is the desired implementation, or did I just find a glaringly obvious bug in the string library I'm using.