Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Defining a function inside the input of another function in C

I have a function which has a function pointer input. I can easily give function names to it as input. But I wonder if it's possible to define a function as input. For example I have a function like this;

void exampleFunction ( void (*functionPointer)( void ) ) {
  codes
  ...
}

Can I give an input like this inside the brackets? For example;

exampleFunction( void helloFunction ( void ) {
  printf("Hello");
} );

It gives compilation error like this but is there any other ways to do it?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is impossible in C.

In C++, you can use a lambda-expression:

exampleFunction([](){ std::cout << "Hello"; });
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!