You ask,
“Would this lead to memory fragmentation?”
Well memory allocation is necessary for fragmentation to occur, but it is not sufficient.
I.e. it depends, on a lot of things, including the pattern of allocations, and the memory manager.
So as stated the question is really unanswerable.
But some good advice can still be given.
Do not use raw arrays and new
, use instead e.g. std::vector
and std::string
.