I have several identical string constants in my program:
const char* Ok()
{
return "Ok";
}
int main()
{
const char* ok = "Ok";
}
Is there guarantee that they are have the same address, i.e. could I write the following code? I heard that GNU C++ optimize strings so they have the same address, could I use that feature in my programs?
int main()
{
const char* ok = "Ok";
if ( ok == Ok() ) // is it ok?
;
}