This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

unable to use fread() function

Hi,

I am working on MCB2300 (with LPC2378 processor). I have written a small function that will read the values into a matrix. But when the control comes to fread it completely hangs up, nothing can be done. Below is the my function which is giving problem

 void loadImage(FILE* arq, unsigned char** Matrix){
        int i,j;
        unsigned char tmp;
        long pos = 51;

        fseek(arq,0,0);

        for (i=0; i<300; i++){
                for (j=0; j<400; j++){
                        pos+= 3;
                        fseek(arq,pos,0);
                        fread(&tmp,3,1,arq);
                        Matrix[i][j] = tmp;
                }
        }
}

Its working fine in GNU C. But when I have tried to use the same code in Keil uVision4, its is not working. Please let me know how to sort this problem

Parents
  • Once done I have compiled it. Compilation is done but I could n't run it. Nothing is printed

    You keep ignoring my suggestions. What's the point in posting about your problems when you ignore the responses?
    How much RAM do you have? Do you have enough of it to hold your bitmap?
    If you define a variable at function scope (a so-called automatic variable), memory for it will be allocated on the stack. I am certain that your stack is not large enough to hold a variable that is 75 Kbytes in size. Hence, the program will not work.

Reply
  • Once done I have compiled it. Compilation is done but I could n't run it. Nothing is printed

    You keep ignoring my suggestions. What's the point in posting about your problems when you ignore the responses?
    How much RAM do you have? Do you have enough of it to hold your bitmap?
    If you define a variable at function scope (a so-called automatic variable), memory for it will be allocated on the stack. I am certain that your stack is not large enough to hold a variable that is 75 Kbytes in size. Hence, the program will not work.

Children
  • In fact, you seem to ignore all responses from all posters!

    "Compilation is done but I could n't run it"

    There you go again - a meaningless statement!

    Why couldn't you run it?

    What, exactly, prevented you from running it?

    What debugging have you done to find the problem?