1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is this the correct way to assign array value?

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

  1. radishcarrot

    radishcarrot New Member

    Sep 20, 2006
    Likes Received:
    Trophy Points:
    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);
    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