Given a string, you need to be divided into words and written in separate arrays. It does not occur to me how to do auto-create arrays. How to implement it?

Closed due to the fact that the essence of the issue is incomprehensible by the participants αλεχολυτ , Kromster , rjhdby , cheops , D-side 20 Oct '16 at 14:11 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Have you heard anything about dynamic arrays? - post_zeew
  • @Firepro I know what multidimensional and dynamic arrays are, BUT you probably did not understand me. I don `t know how many words there will be - based on this - I don` t know how many arrays should be. It does not fit into one array, but in different ...... and ilia here you need to write everything into a dynamic multidimensional array, and in it each new line is this a new one-dimensional array? - Anonim
  • @Anonim Naturally, it is better to write into one multidimensional array and in it each line will be a new one-dimensional array, you will not be able to create variables with different names while the program is running, although you can use code generation, but this is a crutch. - Firepro
  • one
    @Firepro Talk led to the answer)) thanks) - Anonim
  • If possible, publish the solution found in response to your question . I am sure it will help many of your colleagues in the future. - Nicolas Chabanovsky

1 answer 1

In C ++, statically defined arrays must have sizes specified when compiled with a constant expression.

If you do not know in advance the size of the array, then you will have to distribute it dynamically and, possibly, redistribute it.

Instead of manually distributed dynamic arrays, you can use standard containers, such as the standard std::vector container.

As for C, it can optionally support variable length arrays (Variable Length Arrays - VLA).

If your C compiler supports VLA, then you can use them.