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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:32:19+00:00 2026-06-07T22:32:19+00:00

void f() means that f returns nothing. If void returns nothing, then why we

  • 0

void f() means that f returns nothing. If void returns nothing, then why we use it? What is the main purpose of void?

  • 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-07T22:32:20+00:00Added an answer on June 7, 2026 at 10:32 pm

    When C was invented the convention was that, if you didn’t specify the return type, the compiler automatically inferred that you wanted to return an int (and the same holds for parameters).

    But often you write functions that do stuff and don’t need to return anything (think e.g. about a function that just prints something on the screen); for this reason, it was decided that, to specify that you don’t want to return anything at all, you have to use the void keyword as “return type”.


    Keep in mind that void serves also other purposes; in particular:

    • if you specify it as the list of parameters to a functions, it means that the function takes no parameters; this was needed in C, because a function declaration without parameters meant to the compiler that the parameter list was simply left unspecified. In C++ this is no longer needed, since an empty parameters list means that no parameter is allowed for the function;

    • void also has an important role in pointers; void * (and its variations) means “pointer to something left unspecified”. This is useful if you have to write functions that must store/pass pointers around without actually using them (only at the end, to actually use the pointer, a cast to the appropriate type is needed).

    • also, a cast to (void) is often used to mark a value as deliberately unused, suppressing compiler warnings.

      int somefunction(int a, int b, int c)
      {
          (void)c; // c is reserved for future usage, kill the "unused parameter" warning
          return a+b;
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I understand it correctly this means extern void foo(); that the function foo
Mmap returns a void*, but not a volatile void* . If I'm using mmap
I have a function that accepts a string, that is: void log_out(char *); In
I want to access a C function that returns a struct containing double arrays
I am trying to terminate a program if the if statement returns that the
I want to make my application Blackberry in different languages. That mean I use
equals and hashCode method must be consistent, which means that when two objects are
static class MyClass { static void Main() { bool b1 = false; if (
What does public static void mean in Java? I'm in the process of learning.
Question from the one interview. Please explain what does this C++ code mean: void

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.