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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:17:45+00:00 2026-06-11T05:17:45+00:00

A friend told me there is a way to check with printf without modifying

  • 0

A friend told me there is a way to check with printf without modifying the original void function.

But I can’t see how you can do it.

#include<stdio.h>

void test()
{
  int a = 1;
  int b = a;
}

main()
{
    printf("%d",test());    
}

I kept getting

error: invalid use of void expression

Is there a way to do it?

  • 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-11T05:17:47+00:00Added an answer on June 11, 2026 at 5:17 am

    I see from your edit that you want to do this without modifying the function. You can employ the comma operator to make the function call in a printf:

    #include <stdio.h>
    
    void test()
    {
        int a = 1;
        int b = a;
    }
    
    main()
    {
        printf("%d\n", (test(), 0));
    
        // or even this, to be more explicit:
        printf("%s\n", (test(), "test() was called."));
    }
    

    The comma operator evaluates the first operand – in this case your function call – and discards the result, then evaluates the second operand and the result is the result of the entire expression.

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

Sidebar

Related Questions

A friend of mine told me there was a way to connect two private
i have session code it's working fine but some friend told me this code
One of my friend told me about Statement 2 , but thus far I
Does Java have a built-in Antivirus? One of my friends told me there is
One of my friend told me Use font family: helvetica, arial, sans-serif in your
I was told by a friend that compiler inline is better than the manual
I'm trying to reproduce the effect our friend @Dr. Molle told us on this
Some time ago a friend of mine told me not to use realloc because
One of my friend told me that he used a batch program to install
Well, my friend told me I should start using InnoDB for my database, so

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.