是否有可能获得一个函数来返回一个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编程的初学者
设计这样一个功能的理智方式是:
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)
(假设缓冲区不是局部变量)
| 归档时间: |
|
| 查看次数: |
1126 次 |
| 最近记录: |