0

What is the best way to populate array "in fly" when reading file lines?

I found similar solution here

But firstly the programmer looping through the file to get numbers of lanes and then in another loop saving content to structure.

I'm looking for the way how to do it in one loop

3
  • 2
    The accepted to that question answer does just that: push_back into an std::vector Commented Jan 19, 2015 at 23:03
  • Are you thinking of a dynamic array that is not an std::vector? Commented Jan 19, 2015 at 23:06
  • Doesn't matter if is std::vector std:array etc. I'm looking for efficient way :) Commented Jan 21, 2015 at 21:03

1 Answer 1

0

Alternatively, you can use malloc / realloc to read the array with unknown structure on the fly. Use custom unidirectional lists or std::list when it is not memory and access-time critical.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.