-2

I've been having some trouble achieving this functionality. I haven't been able to find code resolving this specific issue anywhere.

Thank you for taking time to help me, it means a lot

Drason
  • 41
  • 1
  • 8
  • 3
    Welcome to Stack Overflow. Please take few moments to take a [tour] and also read [ask] to get better answers for your questions. Especially, please show us what you already have done, so we can build on top of it. – Marek Vitek Jul 14 '17 at 20:56
  • Read up on `fstream`. [These C++ books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) are a good place to start. – Ron Jul 14 '17 at 20:59
  • @Ron I've read that, and tried a bunch of codes, that's why I'm asking for a short code for someone to write that I can use – Drason Jul 14 '17 at 21:03
  • @Ron I even encrypted the text file lines that I write into, but this is just a problem I can't seem to solve – Drason Jul 14 '17 at 21:06
  • 2
    @AndrejBatarilo Read from a file. Skip the lines you do not want. Write the ones you do want to another file. Also this [SO answer](https://stackoverflow.com/questions/5207550/in-c-is-there-a-way-to-go-to-a-specific-line-in-a-text-file) might help. – Ron Jul 14 '17 at 21:14
  • 1
    Read each line in the file with `std::getline` and write each line into `std::vector`. Close the file. `std::vector::erase` the appropriate line (hint `begin()` + lineNo). Open the file and write the contents of the vector over the old file. – user4581301 Jul 14 '17 at 21:37
  • You may get faster results by searching before you post. Search StackOverflow for "c++ delete lines file". There's got to be a plethora of existing similar questions. – Thomas Matthews Jul 14 '17 at 22:49

1 Answers1

1

I made my own getline() with while() in it with an integer that increases with every line, and the number that i entered ignores the number of that line, writes to a new file, removes the original file, and renames the temporary file to the original, many thanks

Drason
  • 41
  • 1
  • 8