Dear experts ,
i want to create a stack of arguments with va_arg, which is getting i think but when i try to read them back, means traverses the stack it gives me null please tell me proper way of cerating and traversing i am trying like this.
Code:
char ss[1000];
char ........_ptr = (char *)((((int)ss)+(7)) & ~7);
char *........_pp = (char **)((((int)ss)+(7)) & ~7);
char *va_curptr = 0;
int ss_cnt=0;
char *sendList(int numArgs,...)
{
int type;
va_list vlist;
va_start(vlist,numArgs);
va_curptr = vlist;
/* assume
0 -> int
* 1 -> float
* 2 -> string
*/
switch(type)
{
case 0:
ss_ptr = (va_arg(vlist,int));
ss_ptr += (vlist - va_curptr);
va_curptr = vlist;
ss_cnt += sizeof(int);
break;
case 1:
ss_fp = (double *)ss_ptr;
ss_fp = ((double *)(&va_arg(vlist,double)));
ss_ptr += (vlist - va_curptr);
va_curptr = vlist;
ss_cnt += sizeof(double);
break;
case 2:
ss_pp = (char **)ss_ptr;
ss_ptr =(char *)(&va_arg(vlist,char *));
ss_ptr += (vlist - va_curptr);
va_curptr = vlist;
ss_cnt += sizeof(char *);
}
return ss;
}
int main()
{
char * temp_ptr = sendList(6,2,"hello",1,12.25,0,34);
//here i want to write a code to get the values of stack how to do.
return 0;
}
so syntactically it is correct please tell proper way of passing any integer , float and string value inot the stack and also how to extract from stack please tell me