Adobe Interview Question
Software Engineer / Developerssomething like:
void myprintf(char *fmt, ...)
{
//va_list arg;
char *pArg;
//va_start(arg, fmt);
pArg = (char *)&fmt;
pArg += sizeof(fmt);
do{
...
//i = va_arg(arg, int);
i = *((int*)pArg);
pArg += sizeof(int);
...
} while(*fmt);
//va_end(arg);
pArg = NULL;
}
during function calls, first parameters gets stored on the stack from right to left(the reason for parameter expression to executes from right to left in a function call)and then return address will store.
- mail2vcp@gmail.com September 29, 2008we have poiner to the const char format(ex: "name = %s, marks = %f")
so just parse this string and werever u get the % specifire, then use the subsequent memory location after the variable which points to this format
thats the actual way(AS I THINK) the variable number arguments works