¿I can delete specific characters of a text file? for example, i have a file text with "123456". I'd like delete the number '3' only. ¿what function can i use?
The new file would be "12456"
File IO? fopen/fread/fwrite/fseek/fclose etc
You'll need to manually manage this, there isn't a magic command to remove characters.
And, how I do it manually?, I want to delete for example the last character, without erasing all the data in the file. "fopen/fread/fwrite/fseek/fclose etc" which I can use?
I always use the function fdeletecharatposition3fromfile() to do this.
Remember to include the library deletecharfromfile.lib. It has a lot of separate functions to delete specific characters from specific positions for files of a specific length. Be warned, it's a very large library because there are a lot of combinations it has to cope with.
If someone does write a number of characters on a ribbon - how do you then remove a character somewhere in the middle of that ribbon without cutting and splicing the ribbon? Erase and write the characters again? Or maybe get a new ribbon and copy the characters you want to keep to the new ribbon?
#include <windows.h> #include <stdio.h> int main(int argc, char **argv) { FILE *f; char *buffer; size_t size; f = fopen("temp.txt","rb"); if (f) { fseek(f, -1, SEEK_END); size = ftell(f); fseek(f, 0, SEEK_SET); buffer = malloc(size); fread(buffer, size, 1, f); fclose(f); f = fopen("temp.txt","wb"); if (f) { fwrite(buffer, size, 1, f); fclose(f); } free(buffer); } // Other architectures might permit // fseek(f, -1, SEEK_END); // fwrite((void *)f, 0, 0, f); // fseek(f, -1, SEEK_END); // ftruncate(f); return(1); }
thanks, you're very kind for your help.