Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is causing this Point-to-Object Error in C?

So I have defined

#define SYS_LEN 50.0
#define N_CELLS ((int)SYS_LEN)

as well as

extern double *array_one

which I populate via

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

array_one[0] = 0.5*SYS_LEN
array_one[1] = 0.25*SYS_LEN

I then go onto define function

void function(void)
{
int is, ix;
double X;
for (is = 0; is < MAX_VALUE; is++){
    for (ix = 0; ix < MAX_VALUE_TWO; ix++)
    {
    X[is] = 0.5 + (double)ix - array_one[is]
    }
}}

However I get an error stating ‘expression must have pointer-to-object type’. Not too sure why this is, any help would be appreciated

Thank you

>Solution :

The problem here is you declared a double scalar with double X, but attempted to access it as though you had declared an array.

Assuming you had defined MAX_VALUE as an integer > 1, the solution would be to declare an array of doubles for X:

For example

#define MAX_VALUE 20

void function(void)
{
int is, ix;
double X[MAX_VALUE];
for (is = 0; is < MAX_VALUE; is++){
    for (ix = 0; ix < MAX_VALUE_TWO; ix++)
    {
    X[is] = 0.5 + (double)ix - array_one[is]
    }
}}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading