js buffer.concat到c strcat

时间:2018-01-26 10:22:08

标签: javascript c

目前,我可以在js中将两个变量合并为一个,我很好奇如何在c中进行等效。

我的js代码:

var buf1 = Buffer.from('a');
var buf2 = Buffer.from('b');
var buf3 = Buffer.from('c');
var arr = [buf1, buf2, buf3];

var buf = Buffer.concat(arr);
console.log(buf);

example output:
<Buffer 37 65 34 30 36 32 62 35 30 33 33 37 33 66 31 34 34 64 37 30 31 34 64 38 66 30 34 30 65 64 31 61 63 35 63 31 31 33 30 32 61 32 66 66 65 38 33 37 38 39 ... >

我的代码:

   char buff[80];
    unsigned char subbuff[64] = "56c5252cd3722bfd3c3147a806bbddaf68b01e020c0cfb60450724a3af45641f";
    unsigned char cipher[64] = "7e4062b503373f144d7014d8f040ed1ac5c11302a2ffe83789015665e955ff09";

    char bgg[16];
    memcpy( bgg, &subbuff[16], 16 );
    bgg[15] = '\0';
    sprintf(buff,"%s%s",bgg,cipher);

I need combine that data which outputs and buffer like.

0 个答案:

没有答案