This code will work. You return a pointer value in StrArray[4]that points to the string constant "BB". Constant lines have a life expectancy equal to the life of your entire program.
The lifetime of the pointer is important, not the location of the pointer. For example, the following similar code will not work:
char* foo(int myNum) {
char bb[3] = "BB";
char* StrArray[5] = {"TEST","ABC","XYZ","AA",bb};
return StrArray[4];
}
, bb foo() , .