Stack overflow while reading bamp image
-
Hello all, I am getting error message: Unhandled exception:Stack overflow.It is due to the declaration of too large array sizes. But how can i overcame that problem The code presented here is given below: FILE *fp1,*fp2,*fp_write,*fpw,*fp_col; int width,height; int buffer,buffer1,buffer3; int k=0,p=0; unsigned int blueValue=0,redValue=0,greenValue=0; unsigned int grayValue=0; unsigned char *pChar; unsigned char someChar; long int iHist[256]; float hist[256]; long int total_pixels=0; int col[257499]; int C[561][459]; int m=0; fp1=fopen("D:\\Pictures\\mod.bmp","rb"); if(fp1==NULL) { printf("file doesn't open"); return; } fseek(fp1,1078,SEEK_SET); k=0; while(!feof(fp1)) { fread(&buffer,1,1,fp1); col[k]=buffer; k++; } int i=0; int j=0; k=0,m=0; for(m=0;m<258878;m++) { C[i][j]=col[k]; j++; k=k+561; if((j%459==0) &(j!=0)) { i=i+1; k=i; j=0; } if(i>561) break; m++; } Regards
-
Hello all, I am getting error message: Unhandled exception:Stack overflow.It is due to the declaration of too large array sizes. But how can i overcame that problem The code presented here is given below: FILE *fp1,*fp2,*fp_write,*fpw,*fp_col; int width,height; int buffer,buffer1,buffer3; int k=0,p=0; unsigned int blueValue=0,redValue=0,greenValue=0; unsigned int grayValue=0; unsigned char *pChar; unsigned char someChar; long int iHist[256]; float hist[256]; long int total_pixels=0; int col[257499]; int C[561][459]; int m=0; fp1=fopen("D:\\Pictures\\mod.bmp","rb"); if(fp1==NULL) { printf("file doesn't open"); return; } fseek(fp1,1078,SEEK_SET); k=0; while(!feof(fp1)) { fread(&buffer,1,1,fp1); col[k]=buffer; k++; } int i=0; int j=0; k=0,m=0; for(m=0;m<258878;m++) { C[i][j]=col[k]; j++; k=k+561; if((j%459==0) &(j!=0)) { i=i+1; k=i; j=0; } if(i>561) break; m++; } Regards
-
Hello all, I am getting error message: Unhandled exception:Stack overflow.It is due to the declaration of too large array sizes. But how can i overcame that problem The code presented here is given below: FILE *fp1,*fp2,*fp_write,*fpw,*fp_col; int width,height; int buffer,buffer1,buffer3; int k=0,p=0; unsigned int blueValue=0,redValue=0,greenValue=0; unsigned int grayValue=0; unsigned char *pChar; unsigned char someChar; long int iHist[256]; float hist[256]; long int total_pixels=0; int col[257499]; int C[561][459]; int m=0; fp1=fopen("D:\\Pictures\\mod.bmp","rb"); if(fp1==NULL) { printf("file doesn't open"); return; } fseek(fp1,1078,SEEK_SET); k=0; while(!feof(fp1)) { fread(&buffer,1,1,fp1); col[k]=buffer; k++; } int i=0; int j=0; k=0,m=0; for(m=0;m<258878;m++) { C[i][j]=col[k]; j++; k=k+561; if((j%459==0) &(j!=0)) { i=i+1; k=i; j=0; } if(i>561) break; m++; } Regards
-
Hello all, I am getting error message: Unhandled exception:Stack overflow.It is due to the declaration of too large array sizes. But how can i overcame that problem The code presented here is given below: FILE *fp1,*fp2,*fp_write,*fpw,*fp_col; int width,height; int buffer,buffer1,buffer3; int k=0,p=0; unsigned int blueValue=0,redValue=0,greenValue=0; unsigned int grayValue=0; unsigned char *pChar; unsigned char someChar; long int iHist[256]; float hist[256]; long int total_pixels=0; int col[257499]; int C[561][459]; int m=0; fp1=fopen("D:\\Pictures\\mod.bmp","rb"); if(fp1==NULL) { printf("file doesn't open"); return; } fseek(fp1,1078,SEEK_SET); k=0; while(!feof(fp1)) { fread(&buffer,1,1,fp1); col[k]=buffer; k++; } int i=0; int j=0; k=0,m=0; for(m=0;m<258878;m++) { C[i][j]=col[k]; j++; k=k+561; if((j%459==0) &(j!=0)) { i=i+1; k=i; j=0; } if(i>561) break; m++; } Regards
Maynka wrote:
int col[257499]; int C[561][459];
In addition to Russell's reply... These too arrays are WAY to big for a typical stack: 2,059,992 bytes!! You'll probably want to allocate thes on the heap :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Maynka wrote:
int col[257499]; int C[561][459];
In addition to Russell's reply... These too arrays are WAY to big for a typical stack: 2,059,992 bytes!! You'll probably want to allocate thes on the heap :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: