简体   繁体   中英

C++ cut char pointer

Is it possible to cut char pointer to remove packet header?

To avoid the loops:

Decryptor dec;
char * datae = new char[_packet[0] - 8];
char * decrypted;
for(int i = 0;i<_packet[0] - 8;i++)
{
    datae[i] = _packet[8+i];
}
decrypted = dec.decrypt(datae, _packet[0]-8);
Decryptor dec;
char * decrypted = dec.decrypt(_packet + 8, _packet); // _packet[0] - 8 is going to give you the value of the character at _packet[0] minus 8, which is not likely to be what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM