They both mean the same - the type will be const char*
in both cases. However, using auto *
stresses (and self-documents) the fact that f()
returns a pointer. And it would signal an error if the function is later changed to return something else (e.g. std::string
in this case).
Which to use is primarily a matter of style. If the code relies heavily on f()
returning a pointer, or you feel the need to make this obvious, use auto*
. Otherwise, just use auto
and be done with it.
Note that the case is different when returning references. Those are dropped by the auto
deduction, so if you need to take a returned reference as a reference, you have to use auto &
(or use auto &&
to get a universal reference).