There are plenty of similar inquires, but in my case I don't understand what isn't working:
int mysize = 0;
mysize = sizeof(samplestring) / sizeof(*samplestring);
std::cout << mysize << '\n' << samplestring;
This outputs:
4
Press 'q' to quit.
How is it possible? 4 definitely isn't the size of this string. I even tried the following, with the same result:
mysize = sizeof(samplestring) / sizeof(samplestring[0]);
EDIT: Ok, this is the declaration:
char *samplestring = "Start.";
I'm on C++, but I need to use functions that only accept char *. Later in the code I assign new strings to that variable, like:
samplestring = "Press 'r' for red text.";
Yes, the compiler gives me warnings, but I have no idea how can I use different strings if I can't overwrite them...
samplestringdeclared?samplestring?