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 8421303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:06:56+00:00 2026-06-10T03:06:56+00:00

I am confuse about the behavior of the following function. Below are some programs

  • 0

I am confuse about the behavior of the following function. Below are some programs on which i stuck:

Case 1:

void f()
{
    printf("wow\t");
}

int main()
{
    f();
    return 0;
}

It gives the output as expected wow.

Case 2:

void f()
{
    printf("wow\t");
}

int main()
{
    f(f());
    return 0;
}

It gives error: invalid use of void expression which is obvious.

Case 3:

int f()
{
    printf("wow\t");
}

int main()
{
    f(f());
    return 0;
}

Why it give the output wow wow?

f() has return type int. But in main it is not stored in any variable. Also f() has not taken any argument but in case 3 it will take argument returned by f().

The same code doesn’t work in C++.

  • 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-06-10T03:06:57+00:00Added an answer on June 10, 2026 at 3:06 am

    The code f(f()); calls f from the inner function call and then calls f from the outer function call. That you don’t store the return value from f doesn’t do anything. The compiler can’t avoid calling a function just because you ignore its return value unless it knows the function has no consequences, and this function does have consequences.

    It’s not unusual at all to ignore the return value of a function. For example, you might have a “remove entries” function that returns the number of entries it removed. You might call that function in a context where you don’t care how many entries it returned, so you ignore the return value. The function still has to run or the entry wouldn’t get removed. Heck, you’re ignoring the return value of printf. You’d be quite surprised if it didn’t get called though.

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

Sidebar

Related Questions

What does the rule about sequence points say about the following code? int main(void)
I have this question about c# language's dynamic binding behavior. Consider the following object
I'm confused about this scope behavior: class Bar: def __init__(self): for fn in [open,openW,remove,mkdir,exists,isdir,listdir]:
I am little bit confuse about log4j in grails. I need to log info
I'm on my way learning about PDO from phpro.org, and a little bit confuse.
I am a little confused about Accept-Encoding . I have Web Service which would
I am confused about a behavior of git checkout. The documentation of git checkout
I have a question about the behaviour of my routes.rb . The following code
My question is about test files by which I mean non-code files on which
testing our install4j-Installer I'm a little confused about the behavior of the Installation location

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.