Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Getting Confusing Output (http://www.go4expert.com/forums/getting-confusing-output-t19974/)

micsom_micsom 3Nov2009 21:14

Getting Confusing Output
 
Hi i am getting a wierd output when i execute this function..Node is a structure
Head can be 1/0...if i give 1, its entering into if(Head == 1)..but then Head's value is changed to 1nNumber(12,13,...the second digit is nNumber). i suspect somehow the stack is getting curropted but not able to find out whr,how..
Code:

int Check_CreateNumberNode(const int Head,int nNumber,Node* pNode,Node** ppNode)
{
  int nRetVal=0;
  if(NULL == *ppNode)
  {
  return 1;
  }
  printf("\nCheck_CreateNumberNode");
 
  if(Head == 1)
  {
        (*ppNode)->Carry=0;
        (*ppNode)->Number=nNumber;
        (*ppNode)->pPrev=NULL;
        (*ppNode)->pNext=NULL;
        printf("\nHead1=%d",Head);
  }else if(Head == 0)
  {
        (*ppNode)->Carry=0;
        (*ppNode)->Number=nNumber;
        (*ppNode)->pPrev=pNode;
        (pNode)->pNext=(Node*)*ppNode;
        (*ppNode)->pNext=NULL; 
        printf("\nHead0=%d",Head);
  }


  return nRetVal;
}


xpi0t0s 4Nov2009 17:29

Re: Getting Confusing Output
 
Insufficient code to determine the problem. Create a minimal testbed that defines Node, and sets up a main function that initialises the smallest possible numberr of Node variables to reproduce the problem, and call Check_CreateNumberNode from that main function. Then post the complete code.

micsom_micsom 5Nov2009 09:50

Re: Getting Confusing Output
 
i was suspecting the problem is with this functon only, but it turned out there was no probs..its my mistake only...


All times are GMT +5.5. The time now is 09:30.