jweinst1
8/5/2017 - 8:17 PM

using goto for error handling in c

using goto for error handling in c

//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;
}