A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C_Tutorial%2FFunction%2FFunction_Pointer</id>
		<title>C Tutorial/Function/Function Pointer - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C_Tutorial%2FFunction%2FFunction_Pointer"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C_Tutorial/Function/Function_Pointer&amp;action=history"/>
		<updated>2026-04-07T05:26:00Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C_Tutorial/Function/Function_Pointer&amp;diff=3364&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C_Tutorial/Function/Function_Pointer&amp;diff=3364&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C_Tutorial/Function/Function_Pointer&amp;diff=3365&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C_Tutorial/Function/Function_Pointer&amp;diff=3365&amp;oldid=prev"/>
				<updated>2010-05-25T10:32:12Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Arrays of Pointers to functions==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int sum(int x, int y){&lt;br /&gt;
  return x + y;&lt;br /&gt;
}&lt;br /&gt;
int product(int x, int y){&lt;br /&gt;
  return x * y;&lt;br /&gt;
}&lt;br /&gt;
int difference(int x, int y){&lt;br /&gt;
  return x - y;&lt;br /&gt;
}&lt;br /&gt;
int main(void){&lt;br /&gt;
  int a = 10;&lt;br /&gt;
  int b = 5;&lt;br /&gt;
  int result = 0;&lt;br /&gt;
  int (*pfun[3])(int, int);           /* Function pointer array declaration */&lt;br /&gt;
  /* Initialize pointers */&lt;br /&gt;
  pfun[0] = sum;&lt;br /&gt;
  pfun[1] = product;&lt;br /&gt;
  pfun[2] = difference;&lt;br /&gt;
  int i;&lt;br /&gt;
  for(i = 0 ; i &amp;lt; 3 ; i++)&lt;br /&gt;
  {&lt;br /&gt;
    result = pfun[i](a, b);           /* Call the function through a pointer */&lt;br /&gt;
    printf(&amp;quot;\nresult = %d&amp;quot;, result);  /* Display the result                  */&lt;br /&gt;
  }&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;result = 15&lt;br /&gt;
     result = 50&lt;br /&gt;
     result = 5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing a pointer of a function to another function==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;/*&lt;br /&gt;
Beginning C: From Novice to Professional, Fourth Edition&lt;br /&gt;
By Ivor Horton&lt;br /&gt;
ISBN: 1-59059-735-4&lt;br /&gt;
640 pp.&lt;br /&gt;
Published: Oct 2006&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int any_function(int(*pfun)(int, int), int x, int y){&lt;br /&gt;
  return pfun(x, y);&lt;br /&gt;
}&lt;br /&gt;
int sum(int x, int y){&lt;br /&gt;
  return x + y;&lt;br /&gt;
}&lt;br /&gt;
int product(int x, int y){&lt;br /&gt;
  return x * y;&lt;br /&gt;
}&lt;br /&gt;
int difference(int x, int y){&lt;br /&gt;
  return x - y;&lt;br /&gt;
}&lt;br /&gt;
int main(void){&lt;br /&gt;
  int a = 10; &lt;br /&gt;
  int b = 5;  &lt;br /&gt;
  int result = 0; &lt;br /&gt;
  int (*pf)(int, int) = sum;          /* Pointer to sum function */&lt;br /&gt;
  result = any_function(pf, a, b);&lt;br /&gt;
  printf(&amp;quot;\nresult = %d&amp;quot;, result );&lt;br /&gt;
  result = any_function(product,a, b);&lt;br /&gt;
  printf(&amp;quot;\nresult = %d&amp;quot;, result );&lt;br /&gt;
  printf(&amp;quot;\nresult = %d\n&amp;quot;, any_function(difference, a, b));&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;result = 15&lt;br /&gt;
     result = 50&lt;br /&gt;
     result = 5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Pointing to functions==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int sum(int x, int y)&lt;br /&gt;
{&lt;br /&gt;
  return x + y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int product(int x, int y)&lt;br /&gt;
{&lt;br /&gt;
  return x * y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int difference(int x, int y)&lt;br /&gt;
{&lt;br /&gt;
  return x - y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  int a = 10;&lt;br /&gt;
  int b = 5; &lt;br /&gt;
  int result = 0;&lt;br /&gt;
  int (*pfun)(int, int);              /* Function pointer declaration      */&lt;br /&gt;
  pfun = sum;             &lt;br /&gt;
  result = pfun(a, b);                /* Call sum() through pointer        */&lt;br /&gt;
  printf(&amp;quot;\npfun = sum             result = %d&amp;quot;, result);&lt;br /&gt;
  pfun = product;         &lt;br /&gt;
  result = pfun(a, b);                /* Call product() through pointer    */&lt;br /&gt;
  printf(&amp;quot;\npfun = product         result = %d&amp;quot;, result);&lt;br /&gt;
  pfun = difference;      &lt;br /&gt;
  result = pfun(a, b);                /* Call difference() through pointer */&lt;br /&gt;
  printf(&amp;quot;\npfun = difference      result = %d\n&amp;quot;, result);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;pfun = sum             result = 15&lt;br /&gt;
     pfun = product         result = 50&lt;br /&gt;
     pfun = difference      result = 5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using array of pointers to functions in one statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int sum(int x, int y){&lt;br /&gt;
  return x + y;&lt;br /&gt;
}&lt;br /&gt;
int product(int x, int y){&lt;br /&gt;
  return x * y;&lt;br /&gt;
}&lt;br /&gt;
int difference(int x, int y){&lt;br /&gt;
  return x - y;&lt;br /&gt;
}&lt;br /&gt;
int main(void){&lt;br /&gt;
  int a = 10;               &lt;br /&gt;
  int b = 5;                &lt;br /&gt;
  int result = 0;           &lt;br /&gt;
  int (*pfun[3])(int, int);           /* Function pointer array declaration */&lt;br /&gt;
  /* Initialize pointers */&lt;br /&gt;
  pfun[0] = sum;&lt;br /&gt;
  pfun[1] = product;&lt;br /&gt;
  pfun[2] = difference;&lt;br /&gt;
  /* Call all three functions through pointers in an expression */&lt;br /&gt;
  result = pfun[1](pfun[0](a, b), pfun[2](a, b));&lt;br /&gt;
  printf(&amp;quot;\n\nThe product of the sum and the difference = %d\n&amp;quot;,&lt;br /&gt;
                                                           result);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;The product of the sum and the difference = 75&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>