Help
Advanced Member level 2
Hi,
Anyone can help me to explain the code?
Why i can't get arg1, arg2, and arg3 actual value?
How can i get the actual value?
Thank You.
Anyone can help me to explain the code?
Code:
int varfunc (char *buf, int id, ...)
{
va_list tag;
va_start (tag, id);
if(id == 0)
{
char i=0, result=0;
int arg1;
char *arg2;
char arg3;
arg1 = va_arg (tag, int); // 27(1Bh) at int address = 0x1B00
arg2 = va_arg (tag, char *);
arg3 = va_arg (tag, char);
arg1 = arg1 + 0x02; // arg1 != 0x0008???
while(arg2[i] != '\0') // arg2[] = {0} ????
{
result = arg2[i];
i++;
}
arg3 = arg3 * 0x02; // arg3 = 0 ???
}
else
{
char i=0, result=0; // static Variable
char *arg1;
char *arg2;
char arg3;
arg1 = va_arg (tag, char *);
arg2 = va_arg (tag, char *);
arg3 = va_arg (tag, char);
*buf = '1';
arg1 = "01";
arg2 = "9876";
arg3 = 100;
while(arg1[i] != '\0')
{
result = arg1[i];
i++;
}
i=0;
while(arg2[i] != '\0')
{
result = arg2[i];
i++;
}
arg3 = arg3 * 0x02; // arg3 != 0x06 ????
}
}
void caller (void)
{
char tmp_buffer [10];
varfunc (tmp_buffer, 0, 4, "Test Code", 2);
varfunc (tmp_buffer, 1, "Test", "Code", 3);
}
Why i can't get arg1, arg2, and arg3 actual value?
How can i get the actual value?
Thank You.