V
vertigo
Hello
I have:
struct packet{
byte type; /*my byte is unsigned char*/
int len;
}
struct packet *p = new struct packet;
p->type=10;
p->len=0;
std::string str="";
for (int i=0; i<5; i++)
str=*((byte*)p+i);
i want to create std::string object which has bytes from p.
(because that string object is later used for Sending() that packet).
My problem is that: when before sending i displayed str some character
values were less than 0 (thru to char instead of unsigned char).
How can i prevent it ?
Second problem is strange. When i displayes str i received:
10, -25, 115, 0, 0.
Why there are -25 and 115 insted of 0, 0 ?
Thanx
Michal
I have:
struct packet{
byte type; /*my byte is unsigned char*/
int len;
}
struct packet *p = new struct packet;
p->type=10;
p->len=0;
std::string str="";
for (int i=0; i<5; i++)
str=*((byte*)p+i);
i want to create std::string object which has bytes from p.
(because that string object is later used for Sending() that packet).
My problem is that: when before sending i displayed str some character
values were less than 0 (thru to char instead of unsigned char).
How can i prevent it ?
Second problem is strange. When i displayes str i received:
10, -25, 115, 0, 0.
Why there are -25 and 115 insted of 0, 0 ?
Thanx
Michal