void function(int a, int b, int c) {
   char buffer1[5];
   char buffer2[10];
   int *ret;

   ret = buffer1 + 12;
   (*ret) += 8;
}

void main() {
  int x;

  x = 0;
  function(1,2,3);
  x = 1;
  printf("%d\n",x);
}

I found this code on smashing the stack tutorial and the code given here is expected to jump"x=1;" assignment statement but the code is not working as desired... anyone please help in explaining and correcting this buffer overflow sample code.

What platform are you compiling this on? Some compilers have built-in stack-smashing protection that would prevent this code from working as expected. If you're using GCC, for example, try the following command: gcc -fno-stack-protector programcode.c