The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 function pointer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

yulisunflower

USA
Posts

Posted - 04/21/2010 :  4:24:25 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 7.5
Operating System:vista

Hi,

Does anyone know that if Origin C support function pointer? Thanks.

Penn

China
644 Posts

Posted - 04/22/2010 :  01:49:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Yes, Origin C does support function pointer. The following code shows a simple example on how to use function pointer.

// define function pointer type
typedef double (*FUNC_POINTER)(double);
  
// define callback function
double func(double a)
{
	return a*2;
}

// function pointer as parameter
double FuncCall(FUNC_POINTER myfunc, double a)  
{
	return myfunc(a) + 1;  // using function pointer
}

// testing function
void testFuncCall()
{	
	double dd = FuncCall(func, 1);  // pass a function as parameter
	out_double("", dd); // shoule output 3
}


Penn
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000