Hey everyone! I am pretty new to C++ (just started this month) and will appreciate if someone can help me here.
I have a text file with the following fixed contents (only two lines, nothing more):
1 2
43 65 123 13 41
83 67 22
I need it to turn into a vector array where I can apply the name.size() to find out the length of the array and also to make use of the integers inside for other purposes.
I have successfully read the text file and added the content using .push_back(). However when I cout the vector .size(), it returns 2 and I realised that it consider each line as an element in the array.
I am not sure how to implement your code into mine. I have edited my original post with the code. The read in .dat file is something I took from another place to try this.
Can you advise on how to implement your code into my existing one?
I guess I don't understand what you're trying to do.
I thought you wanted each line in a separate vector of ints.
But instead you are reading the lines into a single vector of strings.