I often want to do something like this:
unsigned char urlValid[66] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
...or:
unsigned char listOfChar[4] = "abcd";
...that is, initialize a character array from a string literal and ignoring the null terminator from that literal. It is very convenient, plus I can do things like sizeof urlValid and get the right answer.
But unfortunately it gives the error initializer-string for array of chars is too long.
Is there a way to either:
- Turn off errors and warnings for this specific occurrence (ie, if there's no room for null terminator when initialising a char array)
- Do it better, maintaining convenience and readability?
std::stringinstead?