ranayehya
Junior Member level 3
Hello!
I want to concatenate 2 unsigned char (temp and counter) contain hexadecimal numbers and store them in another variable (after) but this code ives me segmentation fault. Could someone help me?
Thanks..
I want to concatenate 2 unsigned char (temp and counter) contain hexadecimal numbers and store them in another variable (after) but this code ives me segmentation fault. Could someone help me?
Thanks..
Code:
#include<stdio.h>
void concat()
{
//unsigned char state[4][4];
unsigned char temp[8] = {0x00 ,0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06,0x07};
unsigned char i, j;
unsigned char after[16] ={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char counter[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
// calculate the length of string s1
// and store it in i
for(i = 0; i <= 7; i++)
{
after[i] = temp[i];
}
for(i = 0; i <= 7; i++)
{
after[8+i] = temp[i];
}
for(i = 0; i <= 15; i++)
{
printf("%s\n", after[i]);
}
/* for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
state[j][i] = counter[i*4 + j];
}
}*/
}
int main()
{
concat();
return 0;
}