como definir o valor char * da string std (c_str ()) não está funcionando

Eu não sei, mas isso não está funcionando para mim, estou obtendo um valor garbege quando tento definir o valor char * da função que retorna a string std:

string foo()
{
  string tmp ="dummy value";
  return tmp;
}

char* cc = (char *) foo().c_str(); // if i remove the casting im getting error 
// when i print the cc i get garbage 
printf("%s",cc);

questionAnswers(5)

yourAnswerToTheQuestion