I am getting null on gcc compiler and segmentation fault on another compiler
Very profound sign of undefined behavior. In your code,
printf("%s",getstr());
actually invokes undefined behavior, as the supplied argument is not the proper type as expected by the supplied format specifier.
To elaborate a bit on this, quoting C11 standard, chapter §6.8.6.4, return statement, 
  If a return statement with an expression is executed, the value of the expression is
  returned to the caller as the value of the function call expression. If the expression has a
  type different from the return type of the function in which it appears, the value is
  converted as if by assignment to an object having the return type of the function.
So, s is returned as if converted to a char, representing a wrong value. That value, when being supplied as the argument to %s, creates all the issues via UB.
Upon encountering UB, the behavior is neither guaranteed nor be predicted.