How to read lines of text from file and put them into an array

前端 未结 3 1297
既然无缘
既然无缘 2020-12-30 17:48

I created a text file love.txt:

i love you
you love me

How do I store them into separate array, namely line1 and

3条回答
  •  心在旅途
    2020-12-30 18:41

    How about this.. .

    vector  v;
    string line;    
    ifstream fin("love.txt");
    while(getline(fin,line)){
        v.push_back(line);
    }
    

提交回复
热议问题