【发布时间】:2009-12-29 04:42:13
【问题描述】:
linux gcc 4.4.1 C99
我只是想知道使用以下技术是否有任何优势。我注意到我正在阅读一些代码,退出号的值上升了,如这段代码 sn-p 所示。
/* This would happen in 1 function */
if(test condition 1)
{
/* something went wrong */
exit(1);
}
if(test condition 2)
{
/* something went wrong with another condition*/
exit(2);
}
或执行以下操作并返回:
/* This would happen in 1 function */
if(test condition 1)
{
/* something went wrong */
return;
}
if(test condition 2)
{
/* something went wrong with another condition*/
return;
}
【问题讨论】: