Hi i am using strcat to Append one string to another. it then puts the result into a buffer. I would like to be able to delete a character at the end of the buffer when the backspace key is pressed. ie press backspace, the cursor moves back one char and the last char in the buffer is removed from the buffer.
is there a function that does the opposite to strcat ie instead of adding a string to a string, one that deletes one char from a string?
please help
thanks,
ed.
Help With Strcat
RE:Help With Strcat
I'd just write over the last character with a null-terminator ('\0'). That effectively shortens the string by one character.
str[strlen(str)-2] = '\0';
Hope that helps
Gnome
str[strlen(str)-2] = '\0';
Hope that helps
Gnome
RE:Help With Strcat
if (len = strlen(str))
str[len - 1] = '\0';
It should be "len - 1", not "len - 2"!
str[len - 1] = '\0';
It should be "len - 1", not "len - 2"!
RE:Help With Strcat
You're right, my mistake. I was thinking that I had to account for an off-by-one with the length of the string (thus, I was thinking strlen(str) - 1 - 1, or strlen(str) - 2).
Thanks for noticing that error
Gnome
Thanks for noticing that error
Gnome