CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

HELP with the pointers

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alfredo



Joined: 15 Nov 2010
Posts: 1

View user's profile Send private message Send e-mail

HELP with the pointers
PostPosted: Mon Nov 15, 2010 11:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 15, 2010 1:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Nov 15, 2010 6:14 pm     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group