i want to get the parameters of a function with unlimited arguments
here is my code, it worked but i get warnings :
arg.c:6: warning: return type defaults to `int'
arg.c: In function `main':
arg.c:8: warning: control reaches end of non-void function
arg.c: In function `myfunc':
arg.c:13: warning: initialization makes pointer from integer without a cast
arg.c:14: warning: assignment makes pointer from integer without a cast
arg.c:15: warning: assignment makes pointer from integer without a cast
arg.c:16: warning: assignment makes pointer from integer without a cast
any one have a better solution ? or solve me these warnings
Code: Select all
#include <stdio.h>
void myfunc(char *, ...);
int get_param(int, int);
main()
{
myfunc("hi how are you", 5, 6);
}
void myfunc(char *str, ...)
{
int *d1,*d2,*d3;
int *address=(int)&str;
d1=(int)get_param(0, (int)*address);
d2=(int)get_param(1, (int) address);
d3=(int)get_param(2, (int) address);
printf("%s\n", (char *)d1);
printf("%d\n", (int)*d2);
printf("%d\n", (int)*d3);
}
int get_param(int n, int addr)
{
int address;
address=(addr)+(n*4);
return address;
}