View previous topic :: View next topic |
Author |
Message |
alfredo
Joined: 15 Nov 2010 Posts: 1
|
HELP with the pointers |
Posted: Mon Nov 15, 2010 11:16 am |
|
|
I've this problem and I don't know what to do:
Code: |
#use standard_io(A)
#define use_portb_lcd TRUE
float halo[10];
int halo2(halo)
{
float a=2.14;
float b=1.1;
int i;
for(i=0;i<10;i++)
{
halo[i]=a*b;
}
}
main()
{
lcd_init();
printf(lcd_putc,"%f",halo[1]);
return(0);
}
|
the error is
Quote: | Error 51 line 15(1,3) : previous identifier must be a pointer halo[i]=a*b;
|
I hope your answers, please ..merci |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Mon Nov 15, 2010 1:18 pm |
|
|
Your problem is mixing global names and local names.
A function definition, should contain the _local_ name and type for varibles passed to it. Local definitions _override_ global ones.
You use the name (without type) for a global variable. in the function definition, so in this function, the variable 'halo', is _not_ a pointer to an array. Hence the error....
Best Wishes |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Mon Nov 15, 2010 6:14 pm |
|
|
Instead of
int halo2(halo)
try
void halo2(float *halo)
By the way, your program doesn't call the halo2() function. I assume you wrote it with the intention of using it! |
|
|
|