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

pointer to function

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







pointer to function
PostPosted: Sat Jan 10, 2004 6:50 am     Reply with quote

what is the proper syntax for a pointer to a function

I have

long * func1;

func1=disp_character;

disp_character is defined
I get a compiler error 'improper use of a function identifier'
am using PCM version 3.169

thanks
Ttelmah
Guest







Re: pointer to function
PostPosted: Sat Jan 10, 2004 6:55 am     Reply with quote

pic user wrote:
what is the proper syntax for a pointer to a function

I have

long * func1;

func1=disp_character;

disp_character is defined
I get a compiler error 'improper use of a function identifier'
am using PCM version 3.169

thanks

The declaration here is saying that 'func1', is a pointer to a function returning a long. The defintion depends on what type the function returns.

Best Wishes
pic_user
Guest







PostPosted: Sat Jan 10, 2004 11:13 am     Reply with quote

still don't work.
a little more details

float c2f(float celsius);



float c2f(float clecius)
{
float f;
f=(celsius*1.8)+32;
return f;
}

main()
{

float c;
float * func1;

func1=c2f;
c=(func1) (32);
}
this is a sample of my code. Not sure whats wrong with it but it won't compile.
error : improper use of function identifier

any help would be greatly appreciated
Ttelmah
Guest







PostPosted: Sat Jan 10, 2004 4:27 pm     Reply with quote

pic_user wrote:
still don't work.
a little more details

float c2f(float celsius);



float c2f(float clecius)
//spelling error here

{
float f;
f=(celsius*1.8)+32;
return f;
}

main()
{

float c;
float * func1;
//declare as:
// float (*func1)(float);
//This says that func1, is a pointer to a function that requires a float
//argument, and returns a float. All parts of this are required.

func1=c2f;
c=(func1) (32);
//Here you need to use the function, not the pointer, so the declaration
//is:
// c=(*func1)(32);

}
this is a sample of my code. Not sure whats wrong with it but it won't compile.
error : improper use of function identifier

any help would be greatly appreciated


This is standard C pointer handling, not a compiler problem. I suggest you read up, on how to use pointers to functions. :-)

Best Wishes
pic_user
Guest







PostPosted: Sat Jan 10, 2004 4:43 pm     Reply with quote

thanks. fixed 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