Truncating a string

Hello, I'm working on a project that reads conditions from an array and adds output to a string based on combinations of true conditions. In order to add together many different pieces of information, I added in a short " + " to the end of each of the pieces of information that are added to the string. This program runs through one hundred some odd lines of code, piecing together the string as it goes. Now I come to the final output, but I can't figure out how to truncate the end of the string, such that the combination text (" + ") is removed, seeing as there is no more possible data to add. I have tried to measure the length of the string via string.length(); and then shift the address over to the + to write over it by doing thus:

int L = string.length();
L--;
string[L] = " ";
string = string.trim();

However, the compiler tells me that I have an invalid conversion from 'const char*' to 'char' and will not compile. Is there a simple way that I can remove the last n characters from a string?

If you just want to truncate it once, stick a null character in where you want it to end. Then it will ignore anything beyond that null. C-strings always end on NULL.

Thank you, that did the trick. I did modify the code, because I forgot that there was still another " " at the end after "+" so I subtracted 3 from the length and set the character there to NULL, ending the string. Thank you much, I kept trying to set it to " " and then trimming it, with no success. The full code will be posted when it's finished, and will be made available to everyone as a tool, I'm actually very excited to release it as it's my first contribution to the open source and electronic hobbyist community. Again, thank you for pointing that out to me.