コード例 #1
0
main()
{
    fpointer = add;		/* Put the address of 'add' in 'fpointer' */
    printf("%d \n", fpointer(4, 5));	/* Execute 'add' and print results */

    fpointer = sub;		/* Repeat for 'sub'			*/
    printf("%d \n", fpointer(6, 2));
}
コード例 #2
0
ファイル: token.c プロジェクト: ddpanasyuk/slap
//Function for checking type of string.
//Essentially compressed replacement for isX()
char* single_to_str(char* src, int (*fpointer)(int)){
	if(fpointer(*src)){
		char* temp=malloc(sizeof(char)*1);
		int i=0;
		for(i=0;fpointer(*src);i++){
			temp[i]=*src;
			temp=realloc(temp,sizeof(char)*i+1);
			src++;
		}
		temp[i]='\0';
		return temp;
	}	
	return 0;
}