c_cpp 在c中使用goto进行错误处理

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 在c中使用goto进行错误处理相关的知识,希望对你有一定的参考价值。

//goto error handling
#include <stdio.h>
 

 



//throwing functon
int caller()
{
  if(0) return 1;
  else goto error;
  
  error: printf("Functiton failed\n");
}


int mul2()
{
  return caller() * 2;
}

int main(void)
{
  mul2();
  return 0;
}

以上是关于c_cpp 在c中使用goto进行错误处理的主要内容,如果未能解决你的问题,请参考以下文章