I have a set of 4 fixed bytes that i put in an array:
Then I want to fill another newarray[1028] with the values of the array above.Code:char fixed[] = "\xcd\xf1\x12\xbf";
(ie 257 X fixed[] inside newarray[1028]) and get something like:
I tried with an ugly loop but I doesn't seem to work:Code:char newarray[1028] = "\xcd\xf1\x12\xbf\xcd\xf1\x12\xbf\xcd\xf1\x12\xbf.........";
Any idea how I can 'replicate' an array n times in another array?Code:int i, j = 0; char fixed[] = "\xcd\xf1\x12\xbf"; char newarray[1028]; for(i=0;i<1028;i++) { if(j > 3) j = 0; newarray[i] = fixed[j]; j++; }



LinkBack URL
About LinkBacks



