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

前端 未结 3 1289
既然无缘
既然无缘 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:25

    Try specifying the last argument as '\n' in both getline() functions:

    getline(myfile, line1[a], '\n');
    

    instead of

    getline(myfile, line1[a], ' ');
    

提交回复
热议问题