| metulburr (278) | |||
i am not really sure what to do. char a[];I thought that this was the way to declare an unknown array? I was initially trying to convert the string into an array of chars.
which gives the error of: test.cpp:21:9: error: storage size of ‘a’ isn’t known | |||
|
Last edited on
|
|||
| cire (2347) | |||
There are no VLAs in C++, so this is not legal code. Array size must be specified by a compile-time constant. char a[];Also not legal code. Use a vector or do some research on dynamic allocation of arrays. | |||
|
|
|||
| Cubbi (1927) | |
A string is already an array of chars. You can obtain a pointer to the first element of that array with &s[0], s.data(), or s.c_str().If you want to copy them out to a vector, it's just vector<char> a(s.begin(), s.end());
| |
|
Last edited on
|
|