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

  • Home
  • SEARCH
  • 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 6223939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:34:42+00:00 2026-05-24T08:34:42+00:00

void func() {assert(0);} int main () {void func();} The above code does not call

  • 0
void func() {assert(0);}
int main () {void func();}

The above code does not call func(), or at least does not reach the assertion. Not that I really need to know, but I’m just curious, what is going on here?

  • 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-24T08:34:43+00:00Added an answer on May 24, 2026 at 8:34 am

    You’re declaring a prototype for a function named func which returns nothing and takes no arguments. That’s (one of) the subtle difference between function calls and function prototypes. Notice that the line above main, the void func() {assert(0);}, has no effect on whether this is a prototype or a call. You could remove it and the code would do the same thing – that is, nothing.

    This also tells you that you can redeclare function prototypes. You could even have this:

    int main() {
        void blah();
        void blah();
        void blah();
        void blah();
    }
    

    And the code would still do what it did before – nothing.

    If you leave off the void, it would call the function.

    Also, notice that in the case of a function which takes parameters, this:

    int main() { func(4); }
    

    would not turn into a prototype if you added void before it like this:

    int main() { void func(4); }
    

    it would just produce a syntax error.

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

Sidebar

Related Questions

I wanted to call Test1() Method Within WaitAndCallFunc() Function. Code: typedef void (*func)(); void
I have a C++ API prototype void Func(int& size); How can I translate it
Confusing title, hopefully some code will clarify: struct MyNestedType { void func(); }; struct
Say a function takes a void pointer as an argument, like so: int func(void
Please check out the following func and its output void main() { Distance d1;
I have a function void func(int x, char *str, ...) { ... } I
Say you have 2 functions: void func(int x,int y,...) { //do stuff } void
I have this kind of code: main() { for(i=0;i<100;i++) { if(cond1) func(1); //Just some
Consider following example. #include <iostream> #include <algorithm> #include <vector> #include <boost/bind.hpp> void func(int e,
void func(int* param){}; func(&123); //error: '&' on constant funct(&int(123)) //error

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.