S
sam.barker0
Hi guys,
I am trying to form an IPV6 address string from the address bytes
contained in a unsigned char buffer
char tempstring[35];
sprintf(tempstring, "%x:%x:%x:%x:%x:%x:%x:%x",htons(*((unsigned short
*)(buf.GetStart()))),htons(*((unsigned short *)(buf.GetStart()
+2))),htons(*((unsigned short *)(buf.GetStart()+4))),htons(*((unsigned
short *)(buf.GetStart()+6))),htons(*((unsigned short *)(buf.GetStart()
+8))),htons(*((unsigned short *)(buf.GetStart()
+10))),htons(*((unsigned short *)(buf.GetStart()
+12))),htons(*((unsigned short *)(buf.GetStart()+14))))
There is a stack over flow when I do this.Its becase tempstring is
char instead of unsigned char.
But sprintf allows only char array.
How can I solve the problem.Is there a better way to write this?
Cheers,
Sam
I am trying to form an IPV6 address string from the address bytes
contained in a unsigned char buffer
char tempstring[35];
sprintf(tempstring, "%x:%x:%x:%x:%x:%x:%x:%x",htons(*((unsigned short
*)(buf.GetStart()))),htons(*((unsigned short *)(buf.GetStart()
+2))),htons(*((unsigned short *)(buf.GetStart()+4))),htons(*((unsigned
short *)(buf.GetStart()+6))),htons(*((unsigned short *)(buf.GetStart()
+8))),htons(*((unsigned short *)(buf.GetStart()
+10))),htons(*((unsigned short *)(buf.GetStart()
+12))),htons(*((unsigned short *)(buf.GetStart()+14))))
There is a stack over flow when I do this.Its becase tempstring is
char instead of unsigned char.
But sprintf allows only char array.
How can I solve the problem.Is there a better way to write this?
Cheers,
Sam