I have a simple program as below:
static const char* DeviceID = (char*)"my id";
int length = strlen(DeviceID);
int main(){
}
and the compiler throw the following error:
initializer element is not constant
I don't know why the compiler can't understand my statement:
strlen's prototype is like the following code:
size_t strlen ( const char * str );
strlenwhere you need it. Or are you using C++? (You specify both tags.)static const char[] DeviceID = "my id";you can usesizeofon it.