S
srinivas reddy
Hi,
I have following questions.
1. Does va_arg allow one to read user defined types. My compiler
allows but I am wondering whether it is true for all.
2. I wrote the following code.
Pardon my omitting declarations etc..
int main()
{
func(10, "baaaaa");
}
void func(int i, ...)
{
va_list ap;
va_start(ap, i);
string* s = va_arg(ap, string*);
va_end(ap);
cout << (int) *s;
}
It prints 0x62616161. Why is this happening. I mean why is it casting
char to int and putting it in int*. And also I couldn't find where the
last two characters are stored. Could some body explain how va_arg
actually works. I know that variable length functions can be
substituted with virtual functions and overloaded functins but I am
curious.
tia,
Srinivas
I have following questions.
1. Does va_arg allow one to read user defined types. My compiler
allows but I am wondering whether it is true for all.
2. I wrote the following code.
Pardon my omitting declarations etc..
int main()
{
func(10, "baaaaa");
}
void func(int i, ...)
{
va_list ap;
va_start(ap, i);
string* s = va_arg(ap, string*);
va_end(ap);
cout << (int) *s;
}
It prints 0x62616161. Why is this happening. I mean why is it casting
char to int and putting it in int*. And also I couldn't find where the
last two characters are stored. Could some body explain how va_arg
actually works. I know that variable length functions can be
substituted with virtual functions and overloaded functins but I am
curious.
tia,
Srinivas