How to delete in File

Apr 11, 2011 at 1:11am
So i have to delete a certain text (or replace it with white space)
in c.

so i have a file:

oranges 556 44 usa
Apples 44 66 ma

now lets say i am at apples with my file pointer, i want to delete everything after till newline so end of ma.
Apr 11, 2011 at 1:26am
I'm not exactly sure what you're asking, can you show some kind of code or explain it with better english?
Apr 11, 2011 at 1:32am
well i have a text file with content:

oranges place:canada season:summer
Apples place:usa season:summer
Kiwi place:Southamerica season:summer

//
now i search through the file, to delete the whole line "Apples place:usa season:summer"
i am not so sure how i can delete just that one line.

i though about,
1. creating a temp file
2. copying everything from this file expect for the line "Apples place:usa season:summer"
3. deleting the original file
4. renaming the temp file to the original name.

but i don't know how to delete a file nor how to rename a file
Apr 11, 2011 at 1:43am
I don't exactly know, I'm a beginner as well, however have you researched into the fstream library? becuase that's almost definitely going to be where you find what you need.
Apr 11, 2011 at 1:48am
i have, but no so help full
Apr 11, 2011 at 1:52am
Ok, gimme a few minutes and I will look into some stuff.
Apr 11, 2011 at 1:57am
Ok, I don't know how this command is used to its full extent, however I think this is what you need http://cplusplus.com/reference/iostream/ostream/write/ if you are going to open and delete from files.
Topic archived. No new replies allowed.