This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

"cannot load from non-primitive location": while trying to read from a .txt file using the fopen() function in C

I am writing an embedded C program on the ARM Cortex-M4 processor. I have saved data from MATLAB in a .txt file and want to read the same in my C code. When I use the fopen() function, I get the "cannot load from non-primitive location" error. Can anyone tell me what I am doing wrong?

FILE *fp = fopen("x_real.txt","r"); Getting NULL pointer here

    // Return if could not open file
    if (fp == NULL)
    {
        printf("Could not open the file");
        return 0;
    }

    do
    {
        // Taking input single character at a time
        char c = fgetc(fp);

        // Checking for end of file
        if (feof(fp))
            break ;

        printf("%c", c);
    }  while(1);

    fclose(fp);