Is there a way to create a dynamic array without necessarily knowing the size beforehand? I need to specifically use a dynamic array for a homework assignment, and I don't really want to ask the user how large the array should be (in this case, an array of chars i.e. a string).
greatman05
0
Newbie Poster
Recommended Answers
Jump to PostYou have to supply a size, but it can be a "best guess" and you can always reallocate later if the guess was wrong. If it's user input from the console, I imagine a buffer of 100 would probably do the job without reallocation in most cases.
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.