Stackoverflow during assigment in another loop

-1

My idea was to read ppm file, read it to 2-dim arrays of chars ( 3, each for R color, G and B), convert and write them to one int. My imagie is 800x600 size( y and x in my for loops

 int charToInt(unsigned char r,unsigned char g,unsigned char b){
            int i;
            i=r*(256*256);//r 
            i=i+(g*256);//g
            i=i+b; //b

            return i;


          }

int main(){

//here's loading image and other values 
 // int to char
    unsigned int tabimage[600][800];

    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
        tabimage[i][j]=charToInt(arrayR[i][j],arrayG[i][j],arrayB[i][j]);
        //cout<<"i="<<i<<" j="<<j<<" tabtabimageobrazu "<<tabimage[i][j]<<endl;
      }
    }
 //char to int
    unsigned char PostR[600][800]; //y  x
    unsigned char PostG[600][800];
    unsigned char PostB[600][800];

       for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
           unsigned int tempInt=tabimage[i][j];
           cout<<tempInt<<endl;
            //PostR[i][j]=i/(pow(256,2));
           // PostG[i][j]=(tempInt-PostR[i][j]*(pow(256,2)))/256;
            //PostB[i][j]=(tempInt-PostR[i][j]*(pow(256,2))-PostG[i][j]*256);
            //cout<<PostR[i][j]<<" "<<PostG[i][j]<<" "<<PostB[i][j]<<endl;

      }
    }
return 0;
}

The thing is that if i try to cout it in first for loop, everything works fine, but whenever i try to do anything in second loophole, i got

Exception thrown at 0x0040216B in a.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x00582F08)

and it doesnt matter whenever i try to cout just from tabimage or at first try to assigne it to diffrent variable. I'm trying to solve this for few days and nothing comes to my mind

c++
c
asked on Stack Overflow Nov 26, 2019 by Saper9

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0