### using pointers to fill arrays

HI!
i am having trouble understanding how to use pointers with arrays. more specifically how to use a pointer to one array to fill a second array. assume i have a 144 bit array, rs_codewords, that has its first 72 positions filled with data and the second 72 positions filled with parity bits. using a pointer to rs_codewords[], i have to put what is in this array into another array, recd[], rearranged so that the first 12 positions will be data, the next 12 positions are parity bits (to create a 24 bit codeword); and so on like that for the rest of the 5 codewords. below is my code so far:
 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546`` ``````#define mm 6 /* RS code over GF(2**6) */ #define nn 24 /* nn=2**mm -1 length of codeword */ #define tt 6 /* number of errors that can be corrected */ #define kk 12 /* kk = nn-2*tt */ int pp [mm+1] = { 1, 1, 0, 0, 0, 0, 1 } ; /* specify irreducible polynomial coeffts */ int alpha_to [nn+1], index_of [nn+1], gg [nn-kk+1] ; int recd [nn], data [kk], bb [nn-kk] ; // 1st parameter is pointer to 144 bit array filled by the hamming decode // 2nd parameter is pointer to 72 bit array filled by this decoder to be used later void ldu1::decode_reed_solomon(uint16_t *rs_codewords, uint16_t *decoded_lcw) { generate_gf( ) ; gen_poly( ) ; for(int index = 0; index < 6; index++) { /* takes the 144 bits in rs_codewords array filled by the hamming decoder the first 72 bits are data, the last 72 bits are parity there are 6 24-bit codewords, first 12 bits are data, last 12 bits are parity bits */ // create the codewords, put data and parity in right places int i; for (i=0; i

similarly, i am concerned that memcopy() will not work for the purpose of filling an array with the values in another array via pointer:
 ``12345678910`` ``````void ldu1::decode_hamming( uint16_t *encoded_lcw, uint16_t *rs_codewords ) { // get 24 10-bit codewords out of 240 bit encoded_lcw array for (int index = 0; index < 24; index++) { int edata[10] = {0}; // put each 10 bit coeword in edata[] for decoding memcpy(edata, (encoded_lcw+10*index), 10); // will this work?? pointer points to only encoded_lcw[0]?? ``````

any help will much appreciated. Thanks in advance.
Last edited on
Topic archived. No new replies allowed.