0
C++:How to declare a DynamicArray of String?
I'm a noob, yes I am. I am trying to declare a dynamic array of string(lets call it words_arr) to store words from other sentence(it means each member of words_arr cannot have gap between any alphabet in it, its one word). Btw here's the code: #include <string> int main() { string words_arr[]; return 0; } And it reports that the array size is missing. I do need help, cuz i've tried quite a lot of other way to do this, but it's just giving me different errors. Thanks in advance
1 Odpowiedź
+ 7
The error message is self explanatory, you did not specify how many elements you want the array to have. It's like saying "I need boxes to put these in!" but the guy you talk to has no idea how many boxes you want.
For dynamic container that can grow and shrink as necessary, please look at this intro for vectors
https://www.sololearn.com/learn/261/?ref=app