hello, so today i came across this little problem. Im trying to make an array inside of struct, its all fine, but the thing is that i dont know the size of that array yet. How do i set the size during the runtime?
-Thank you!!!:)
example:
1 2 3 4 5 6 7 8 9 10
struct pav
{
int something[];
};
int main()
{
pav structoreOfPav;
structoreOfPav.something[13] = 10;
}
With pointers, you have to manually manage ownership of the allocated data and make sure that delete[] is called exactly once when you are done with it. There are many obscure ways to get it wrong and it is really difficult even for professional programmers to get it right in all cases.
With containers like std::vector all the hard work is done for you and you even get a nice interface as a bonus.