hello wrote a simple keylogger in c + + backspace button, I would like to work in such a way that after you click opens the file are stored into the characters from the keyboard and removes the last character from a file
how to do?
How to delete the last character from a text file without knowing the number of characters in a file
Don't do that. If for no other reason then you are making random guesses about the file format.
if you have created the keylogger which writes to this text file then you are not making random guesses about structure of the file.
How can truncate the file size -1? byte
try using the [_chsize] function.
I also wondered why you needed to remove last character from file but considered it may be part of your application logic like not wanting to persist the last exiting character ... what are your reasons?
if you have created the key logger which writes to this text file then you are not making random guesses about structure of the file.
That was actually directed at you... Sorry for not making that clear. It's an honest mistake to just assume that someone who is writing in English is using standard ASCII, but the OP didn't mention whether he was using Unicode or Multi-byte. Where as with my solution it becomes a non-issue.