Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef CALLBACK_H
|
||||
#define CALLBACK_H
|
||||
|
||||
/*
|
||||
* By declaring the function in a separate file, we allow
|
||||
* it to be used by other source files.
|
||||
*
|
||||
* It also stops ICC from complaining.
|
||||
*
|
||||
* If you don't want to use it outside of callback.c, this
|
||||
* file can be removed, provided the static keyword is prepended
|
||||
* to the definition.
|
||||
*/
|
||||
void map(int* array, int len, void(*callback)(int,int));
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#include <stdio.h>
|
||||
#include "callback.h"
|
||||
|
||||
/*
|
||||
* We don't need this function outside of this file, so
|
||||
* we declare it static.
|
||||
*/
|
||||
static void callbackFunction(int location, int value)
|
||||
{
|
||||
printf("array[%d] = %d\n", location, value);
|
||||
}
|
||||
|
||||
void map(int* array, int len, void(*callback)(int,int))
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
callback(i, array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int array[] = { 1, 2, 3, 4 };
|
||||
map(array, 4, callbackFunction);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue