C - 是否可以使用返回char*或int的函数?

Tho*_*ond -1 c

是否有可能获得一个函数来返回一个int或一个char*取决于执行时发生的事情?我已经尝试了无效但在编译时我得到了很多警告

void int_char(char *str)
{
    if (I 'm matching a condition in my string)
        return (str);
    else
        return (0);
}
Run Code Online (Sandbox Code Playgroud)

我希望我足够清楚.PS:我是C编程的初学者

Lun*_*din 5

设计这样一个功能的理智方式是:

char* get_buffer (const char *str)
{
  if (I'm matching a condition in my string)
    return buffer;
  else
    return NULL;
}
Run Code Online (Sandbox Code Playgroud)

(假设缓冲区不是局部变量)