delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/18/09:18:24

From: "George Kinney" <goober AT mail DOT net>
Subject: Re: How to declare pointers
Newsgroups: comp.os.msdos.djgpp
References: <01bc8e70$7560c9d0$0417a8c0 AT aksoft-nt> <5qjteg$nl2 AT ds2 DOT acs DOT ucalgary DOT ca>
Organization: The Unknown Programmers
Message-ID: <01bc9322$2bbfea20$ed8033cf@pentium>
NNTP-Posting-Host: 207.51.128.237
Date: 18 Jul 97 02:18:53 GMT
Lines: 32
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Paul Szuch <dunkelzan AT geocities DOT com> wrote in article
<5qjteg$nl2 AT ds2 DOT acs DOT ucalgary DOT ca>...
> On a vaguely related note: how do you declare pointers to functions?
> 

void a_function( int a )
{
	printf( "%i\n", a );	
}

void another_function( void (*func)(int) )
{
	func( 1 );
}

int main( void )
{
	void (*func_to_call)(int);

	func_to_call = a_function;

	another_function( func_to_call );
}


so, a function with no args:
void (*func)();

a functions that takes an int and a char*
void (*func)(int,char *);

I think you can carry on from here. :)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019