here i m showing ma code....its not the whole code but the structure the calling function and the called push function....plz help me tell how to extract data for the void pointer which is pointing to some value......
Code:
typedef struct stStack
{
int ntop;
void* pvitem;
}Stack;
pop(m_stack,nty);
void pop(Stack *m_sstack,ettype nty)
{
if(m_sstack->ntop==-1)
{
printf("\nstack underflow");
}
else if(nty==1)
{
int nnum;
nnum=*((int*)(m_sstack->pvitem[m_sstack->ntop]));
printf("\npoped no. is %d",nnum);
}
else if(nty==2)
{
char nnum;
nnum=*((char*)(m_sstack->pvitem[m_sstack->ntop]));
printf("\npoped no. is %c",nnum);
}
else if(nty==3)
{
float nnum;
nnum=*((float*)(m_sstack->pvitem[m_sstack->ntop]));
printf("\npoped no. is %f",nnum);
}
else
{
double nnum;
nnum=((double*)(m_sstack->pvitem[m_sstack->ntop]));
printf("\npoped no. is %f",nnum);
}
}
here nty is the type of the stack which user provide...
Comment