Modify selected text from a textfile

Case Solved..
Last edited on
what are you trying to do with this line?

data[] = edit;
I got it from a website where they want to change

100 50 20 90
4.07498 0.074984
37.1704 28.1704
20.3999 14.3999
48.627 35.627 ....


3rd line change from 20 to 19.98

100 50 19.98 90
4.07498 0.074984
37.1704 28.1704
20.3999 14.3999
48.627 35.627
....


The issue is, the array is already preset in the code.
What I want is that the user able to select the string they want and remove it, not by preset it. Is there any other method I can do it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <fstream>
#include <ios>
#include <iterator>
#include <vector>

int main() { 
    std::vector<double> data;

    std::fstream file("yourfile.txt", std::ios::in | std::ios::out);
    std::copy(std::istream_iterator<double>(file), 
        std::istream_iterator<double>(),
        std::back_inserter(data));
    file.clear();
    file.seekp(0);
    data[2] = 19.98;
    std::copy(data.begin(), data.end(), std::ostream_iterator<double>(file, " "));
    return 0;
}
Last edited on
Is there any method u all recommend? I saw string tokenizer but kinda confused on how they work
I am actually not able to understand the problem.
Thx thou, I think I somehow managed to solve it!! Haha!!
Topic archived. No new replies allowed.