0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【tips】int (*a(void))(int); これ分かりますか?

Last updated at Posted at 2023-01-16

答えは、関数アドレスを返す関数です。
使い方はこんな感じです。

#include <stdio.h>

int sub(int p) { return 123 + p; }		//ここの値が下記のprintfで表示される
int (*a(void))(int) { return sub; }		//sub関数のアドレスを返す
int main(void)
{
	printf("%d\n", a()(0));
    return 0;
}
0
0
8

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?