N
N
nimbus2142021-11-28 18:55:18
C++ / C#
nimbus214, 2021-11-28 18:55:18

How to read an entire line from a file into an array?

Good evening, how to read a whole line into an array from a file?

fin >> x;
  string* arr = new string[x];
  for (int i = 0; i < x; i++) {
    fin >> arr[i];
  }

The file has X number of lines, but they have spaces and fin doesn't read the lines correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-11-28
@nimbus214

Use getline .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question