I'm working on a c++ file and I've encountered an interesting problem. I'm outputting strings into a text file (using ofstream) and I have the following lines.
void InstructionWriter::outputLabel(string s){
string sLabel;
sLabel = s;
sLabel.erase(remove(sLabel.begin(), sLabel.end(), ' '),sLabel.end());
sLabel = "(" + function + "$" + sLabel + ")\n" ;
outputFile << sLabel;
}
The problem is during the txt file it outputs.
When I head to the text file where outputLabel was run, highlighting the line counts the characters +1 character. that +1 is "invisible." Highlighting the line won't select it. The only way to fix it is to start deleting from the right. After you hit the ')' I'll notice that I hit delete again but the cursor didn't move and it seems like nothing got deleted.
I think It's sneaking in a zero width character but I don't know how to strip that from the string, does anybody have any ideas on what functions to look into?
@smac89
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_replace
0
That is what the terminal threw at me after running that command you mentioned.