for loops with double pointers

Discussion in 'C' started by reverbtank, Jun 19, 2008.

  1. reverbtank

    reverbtank New Member

    Joined:
    Jun 19, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi, I'm debugging a program that frequently will read a fits file image and store it in an array, the most frequent way that the original programmer did this was by using nested for loops to first handle the rows and then the columns of the array. I'm still new to programing and get very confused by pointers especially when they are to arrays. Could someone give me a precise, explanation to the following sample for loop with close attention to the pointers and double pointers in terms of the function, function arguments and declared variables?

    double **remove_bright(double **img, int w, int h)
    {
    double **new_img;
    int i, j, ii, jj;

    //copy image for processing
    new_img = new double*[w];
    for (i = 0; i<w; i++)
    {
    new_img = new double[h];
    for (j = 0; j < h; j++)
    new_img [j] = img [j];
    }
    ...of course the code goes on...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice