Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 976943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:49:34+00:00 2026-05-16T03:49:34+00:00

The code states: void (* log_msg)(char *msg) =printf; void change_and_log(int *buffer, int offset, int

  • 0

The code states:

void (* log_msg)(char *msg)
    =printf;

void change_and_log(int *buffer, int offset, int value){
    buffer[offset] = value;
    log_msg("changed");
}

I’m most concerned with the first part:

Firstly, what does the signature void (* log_msg)(char *msg) mean? Is this code simply mapping the function log_msg to printf? In that case, why is the function name (* log_msg) and not simply log_msg?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:49:35+00:00Added an answer on May 16, 2026 at 3:49 am

    It’s a function pointer.

    The type of a function pointer is R (*)(Args...), where R and Args... are replaced with the return type and arguments, if any. It is read as “a pointer to a function that takes arguments Args... and returns R.”

    Your code would read easier as:

    // print_function is a type that is a function pointer
    typedef void (*print_function)(char *msg); 
    
    // log_msg is a variable of the type print_function: it points to a function
    print_function log_msg = printf; // point to printf
    

    And later, it’s just calling that function via a function pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm executing this code: void update_process(PROCSP * process){ int state; printf(process.pid = %d\n, process->pid);
I have a code like this: class PacketDAO{ //... public void UpdatePacketStatus(Guid packetID, Status
Below I have a line of code where it states which Session a user
Brad Wilson states that The default templates in ASP.NET MVC are done in code.
This is my code. #import "States.h" @interface States () + (NSString *)statesFilePath; @end static
I have the following css code. button.png is image where 3 button states are
I am reading the tutorial at http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ It states Remember - you must never
I have the following code: char stats[109]; /* !LINE UNDER QUESTION! */ sprintf(stats, OBJECTS:\n%u/256\n
I've written a small BluetoothReceiver, which handles most of the BT states. The receiver
Hy! My code: Thread thread = new Thread (){ @Override public void run() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.