how i can put 2d array to a pointer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arda
    New Member
    • Oct 2006
    • 6

    how i can put 2d array to a pointer

    how i can put 2d array to a pointer? In the below program i am giving a first value to output_bit and then start to a loop and putting the new values to an another array as called newdata[l][k]. But as i understand from this loop the last value of the 2d array u[l][k] is not put to newdata[l][k]. Because of the first value of output_bit which is given in he beginning. In 1d array it is easy to solve this problem that you can put output_bit data in the for loop to the new data as newdata[k-1] but 2d array it is not possible to do this. So how can i solve this problem?????? Thanks for your interest.....



    output_bit=0
    for (l = 0; l < K; l++) {
    for (k = 0; k < K; k++) {
    if (u[l][k] == 0)
    output_bit =1 - output_bit;
    newdata[l][k] = output_bit;
    }}
  • arda
    New Member
    • Oct 2006
    • 6

    #2
    have a 2D array problem in the program

    how i can put 2d array to a pointer? In the below program i am giving a first value to output_bit and then start to a loop and putting the new values to an another array as called newdata[l][k]. But as i understand from this loop the last value of the 2d array u[l][k] is not put to newdata[l][k]. Because of the first value of output_bit which is given in he beginning. In 1d array it is easy to solve this problem that you can put output_bit data in the for loop to the new data as newdata[k-1] but 2d array it is not possible to do this. So how can i solve this problem?????? Thanks for your interest.....



    output_bit=0
    for (l = 0; l < K; l++) {
    for (k = 0; k < K; k++) {
    if (u[l][k] == 0)
    output_bit =1 - output_bit;
    newdata[l][k] = output_bit;
    }}

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Please don't double post.

      Your question is not clear, assuming that K is the size of both dmensions of the array then the code posted writes all of newdata for which u is non-zero including the last entry newdata[K-1][K-1]

      Comment

      Working...