scanf is skipped
<p>I have the following code and I have defined the functions that I am calling here, the problem here is : I run the code 
input: 1
input: 2
input: 2
input: 6
input: 5 6 // for the scanf associated with i=6;
after this I get the output on the screen as 
enter ur choice and then it exits out of the program ... its like the scanf gets the value from somewhere but I dunno from where I also tried fflush(stdin) doesnt seem to work can any one please help</p>

<pre><code>int main()
{

  int i,*j,k,pos,val;
  Element *stacka = new Element;

  stacka =NULL;

  while(i!=5)
  {

    printf("Enter ur choice \n");
    fflush(stdin);
    scanf("%d",&amp;i);

    if(i==1)
    {
      if(createStack(&amp;stacka))
      {
        printf("yes");

      }
    }

    if(i==2)
    {
      k=2; 
      if(push(&amp;stacka,&amp;j))
      {
        printf("yes");

      }
    }

    if(i==3)
    {
      if(pop(&amp;stacka,&amp;k))
      {

        printf("yes %d",k);


      }
    }

    if(i==4)
    {
      if(emptyStack(&amp;stacka))
      {
        printf("yes");

      }
    }

    if(i==6)
    {
      scanf("%d,%d",&amp;pos,&amp;val);
      fflush(stdin);
      insert_at_pos(pos,val,&amp;stacka);

    }

  }
return 0;
}
</code></pre>
