Reading text file as an array

Hello I need help reading text file as an array and line by line.
Lets say I have a text file

[4: 1 2 3 4]
[3: 22 77 101]
[4: aa ab bb ba]
[8: xx yy cc dd aa kk tt eight]

The output should be:

[1 2 3 4]
[22 77 101]
[aa ab bb ba]
[xx yy cc dd aa kk tt eight]

I am unsure how to do this so far I have just opening the file. What I plan to do is read the first integer, and set it as the size of my array, then go through each int/string and put it into my index of the array.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include<fstream>

template<typename T>
class A{
int size = 0;
T array = new T[size];
}
int main(){

  std::string line;
  ifstream myfile("input.txt");
    if(myfile.is_open()){
      while(std::getline(myfile,line)

      myfile.close();
    }
    else{
      cout << "Unable to open file" << '\n';
    }
  }
return 0;
}
Topic archived. No new replies allowed.