Deleting

I want to delete a part of file not the complete file . How i can do it using file handling.
If you mean a text file, there's no way of deleting a single line from a text file you have to rewrite the whole file leaving out the parts you wanted to delete
Copy it in chunks and simply don't copy the bits you don't want.

In file handling terms, open it, read a bit, write it to a new file, repeat many times until you get to the bit you don't want to copy, skip over that (and if you want it blanked rather than gone, write whatever counts as blank data), read and write some more, close both files.
Last edited on
Actually i am trying to sort a file with integers written into it . I am doing that with merge sort . My program is working correctly for 1 GB file but it is not working for 10 GB . Its giving an error "std::bad_alloc" . I searched about this error and come to know that its an memory allocation error . It mean that i have to reduce the space used by my program . Thats why i want to delete the part i have read once but i don't know how to reduce the space used. Can anybody help me???
Topic archived. No new replies allowed.