Is this the correct way to assign array value?

Discussion in 'C' started by radishcarrot, Sep 20, 2006.

  1. radishcarrot

    radishcarrot New Member

    Joined:
    Sep 20, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    unsigned char *m_pVolumeData;
    m_pVolumeData = new unsigned char[m_nSizeX * m_nSizeY * m_nSizeZ];
    
    FILE *fp = fopen(filename, "rb");
    if(fp) {
          fread(m_pVolumeData, 1, m_nSizeX * m_nSizeY * m_nSizeZ, fp);
          fclose(fp);
    
    }
    
    unsigned char *pSrcPixels = new unsigned char[m_nSizeX * m_nSizeY];
    for(int m=0; m<m_nSizeX * m_nSizeY; m++) { //copy the value to psrcpixels
         //is this the correct way to assign the value to another array??
          pSrcPixels[m] = m_pVolumeData[sliceNo * (m_nSizeX * m_nSizeY)+m];
    
    }
    Hi, like to check with you all.

    Whether within the for loop, assigning the values are correct? I was to assign the value of m_pVolume to pSrcPixels but it doesnt seem to assign it correct. Pls help.
     

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