Dynamic memory Allocation over Variable Length Arrays

Hi der!! I have a question to ask in C / C++?

Q. While creating larger programs it is beneficial to use Dynamic memory allocation (DMA) or defining variable length arrays (VLA). In DMA memory is allocated from heap during run time and in the latter case, memory is allocated during compile time. But, what is appropriate way of using DMA over VL arrays in larger programs?

e.g. If I need to compare certain strings of variable lengths in a larger program , it is more efficient by using VLA and not by DMA ? Why??

the strings that are to be compared are acutally read from a file in C.
C99 variable length arrays are not there in C++.

In C++, use std::vector<> and std::string.
Topic archived. No new replies allowed.