char *temp = "string"; will create a pointer temp that points to a string litteral. This string literal is stored in the data segment of the executable code. It is immutable and the address is still valid after the function returns.
char temp[] = "string"; will allocate 7 characters on the stack and set them equal to 'string'. These are mutable characters. In your example, theythe returned value points to characters that are destroyedno longer valid when they function returns.