Void is considered a data type (for organizational purposes), but it is basically a keyword to use as a placeholder where you would put a data type, to represent "no data".

Hence, you can declare a routine which does not return a value as:

void MyRoutine();

But, you cannot declare a variable like this:

void bad_variable;

However, when used as a pointer, then it has a different meaning:

void* vague_pointer;

This declares a pointer, but without specifying which data type it is pointing to.

Answer from James Curran on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › c language › void-pointer-c-cpp
void Pointer in C - GeeksforGeeks
malloc() and calloc() return void * type and this allows these functions to be used to allocate memory of any data type (just because of void *).
Published   July 17, 2014
Top answer
1 of 3
106

Void is considered a data type (for organizational purposes), but it is basically a keyword to use as a placeholder where you would put a data type, to represent "no data".

Hence, you can declare a routine which does not return a value as:

void MyRoutine();

But, you cannot declare a variable like this:

void bad_variable;

However, when used as a pointer, then it has a different meaning:

void* vague_pointer;

This declares a pointer, but without specifying which data type it is pointing to.

2 of 3
38

Yes, void is a type. Whether it's a data type depends on how you define that term; the C standard doesn't.

The standard does define the term "object type". In C99 and earlier; void is not an object type; in C11 and later, it is. In all versions of the standard, void is an incomplete type. What changed in C11 is that incomplete types are now a subset of object types. This is just a change in terminology. (The other kind of type is a function type.)

C99 6.2.6 paragraph 19 says:

The void type comprises an empty set of values; it is an incomplete type that cannot be completed.

The C11 standard changes the wording slightly:

The void type comprises an empty set of values; it is an incomplete object type that cannot be completed.

This reflects C11's change in the definition of "object type" to include incomplete types. It doesn't really change anything about the nature of type void.

The void keyword can also be used in some other contexts:

  • As the only parameter type in a function prototype, as in int func(void), it indicates that the function has no parameters. (C++ uses empty parentheses for this, but they mean something else in C (prior to C23).)

  • As the return type of a function, as in void func(int n), it indicates that the function returns no result.

  • void* is a pointer type that doesn't specify what it points to.

In principle, all of these uses refer to the type void, but you can also think of them as just special syntax that happens to use the same keyword.

🌐
GeeksforGeeks
geeksforgeeks.org › c language › data-types-in-c
Data Types in C - GeeksforGeeks
C is a statically type language where each variable's type must be specified at the declaration and once specified, it cannot be changed. In this article, we will discuss the basic (primary) data types in C.
Published   June 30, 2015
🌐
GeeksforGeeks
geeksforgeeks.org › c-data-types-question-6
C | Data Types | Question 6 - GeeksforGeeks
June 28, 2021 - (A) 0 (B) Compiler Error (C) Garbage Value Answer: (B) Explanation: void is not a valid type for declaring variables. void * is valid though.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › can-we-have-an-array-of-all-types-in-c
What are the data types for which it is not possible to create an array? - GeeksforGeeks
July 23, 2025 - Instead, functions are referenced by their addresses when needed, but they cannot be stored as array elements. The void data type represents the absence of a value, and it cannot hold any data.
🌐
Rebus Community
press.rebus.community › programmingfundamentals › chapter › void-data-type
Void Data Type – Programming Fundamentals
December 15, 2018 - The void data type is typically used in the definition and prototyping of functions to indicate that either nothing is being passed in and/or nothing is being returned. ... A data type that has no values or operators and is used to represent ...
🌐
Wikipedia
en.wikipedia.org › wiki › Void_type
Void type - Wikipedia
2 weeks ago - The void type, in several programming languages, more so curly bracket programming languages derived from C and ALGOL 68, is the return type of a function that returns normally, but provides no result value to its caller. Usually such functions are called for their side effects, such as performing ...
🌐
freeCodeCamp
freecodecamp.org › news › data-types-in-c-integer-floating-point-and-void-explained
Data Types in C - Integer, Floating Point, and Void Explained
February 1, 2020 - My value is 1 and my size is 4 bytes. Hello! I am a double floating point variable. My value is 3.140000 and my size is 8 bytes. Bye! See you soon. :) The void type specifies that no value is available.
Find elsewhere
🌐
YouTube
youtube.com › watch
C - Void Data Types - YouTube
C - Void Data TypesWatch More Videos at: https://www.tutorialspoint.com/videotutorials/index.htmLecture By: Mr. Anadi Sharma, Tutorials Point India Private L...
Published   January 11, 2018
🌐
GeeksforGeeks
geeksforgeeks.org › computer science fundamentals › void-pointer-in-programming
Void Pointer in Programming - GeeksforGeeks
July 23, 2025 - In languages like C and C++, void pointers help in making functions polymorphic in nature by allowing them to deal with any kind of data item. ... Here, ptr is a pointer whose type is void, and these two symbols represent ‘pointer to void’. ...
Top answer
1 of 5
11

In C language the void type has been introduced with the meaning of 'don't care' more than 'null' or 'nothing', and it's used for different scopes.

The void keyword can reference a void type, a reference to void, a void expression, a void operand or a void function. It also explicitly defines a function having no parameters.

Let's have a look at some of them.


The void type

First of all void object exists and have some special properties, as stated in ISO/IEC 9899:2017, §6.2.5 Types:

  1. The void type comprises an empty set of values; it is an incomplete object type that cannot be completed.

Pointers

The more useful reference to void, or void *, is a reference to an incomplete type, but itself is well defined, and then is a complete type, have a size, and can be used as any other standard variable as stated in ISO/IEC 9899:2017, §6.2.5 Types:

  1. A pointer to void shall have the same representation and alignment requirements as a pointer to a character type.

    Similarly, pointers to qualified or unqualified versions of compatible types shall have the same representation and alignment requirements.

    All pointers to structure types shall have the same representation and alignment requirements as each other.

    All pointers to union types shall have the same representation and alignment requirements as each other.

    Pointers to other types need not have the same representation or alignment requirements.


Casting to void

It can be used as cast to nullify an expression, but allowing the completion of any side effect of such expression. This concept is explained in the standard at ISO/IEC 9899:2017, §6.3 Conversions, §6.3.2.2 void:

  1. The (nonexistent) value of a void expression (an expression that has type void) shall not be used in any way, and implicit or explicit conversions (except to void) shall not be applied to such an expression.

    If an expression of any other type is evaluated as a void expression, its value or designator is discarded. (A void expression is evaluated for its side effects.)

A practical example for the casting to void is its use to prevent warning for unused parameters in function definition:

int fn(int a, int b)
{
    (void)b;    //This will flag the parameter b as used 

    ...    //Your code is here

    return 0;
}

The snippet above shows the standard practice used to mute compiler warnings. The cast to void of parameter b acts as an effective expression that don't generate code and marks b as used preventing compiler complains.


void Functions

The paragraph §6.3.2.2 void of the standard, covers also some explanation about void functions, that are such functions that don't return any value usable in an expression, but functions are called anyway to implement side effects.


void pointers properties

As we said before, pointers to void are much more useful because they allow to handle objects references in a generic way due to their property explained in ISO/IEC 9899:2017, §6.3.2.3 Pointers:

  1. A pointer to void may be converted to or from a pointer to any object type.

    A pointer to any object type may be converted to a pointer to void and back again; the result shall compare equal to the original pointer.

As practical example imagine a function returning a pointer to different objects depending on input parameters:

enum
{
    FAMILY,     //Software family as integer
    VERSION,    //Software version as float
    NAME        //Software release name as char string
} eRelease;

void *GetSoftwareInfo(eRelease par)
{
    static const int   iFamily  = 1;
    static const float fVersion = 2.0;
    static const *char szName   = "Rel2 Toaster";

    switch(par)
    {
        case FAMILY:
            return &iFamily;
        case VERSION:
            return &fVersion;
        case NAME:
            return szName;
    }
    return NULL;
}

In this snippet you can return a generic pointer that can be dependent on input par value.


void as functions parameter

The use of void parameter in functions definitions was introduced after the, so called, ANSI-Standard, to effectively disambiguate functions having variable number of arguments from functions having no arguments.

From standard ISO/IEC 9899:2017, 6.7.6.3 Function declarators (including prototypes):

  1. The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters.

Actual compilers still support function declaration with empty parenthesis for backward compatibility, but this is an obsolete feature that will eventually be removed in future release of standard. See Future directions - §6.11.6 Function declarators:

  1. The use of function declarators with empty parentheses (not prototype-format parameter type declarators) is an obsolescent feature.

Consider the following example:

int foo();         //prototype of variable arguments function (backward compatibility)
int bar(void);     //prototype of no arguments function
int a = foo(2);    //Allowed
int b = foo();     //Allowed
int c = bar();     //Allowed
int d = bar(1);    //Error!

Now resembling your test, if we call the function bar as follows:

int a = 1;
bar((void)a);

Triggers an error, because casting to void an object doesn't null it. So you are still trying to pass a void object as parameter to a function that don't have any.


Side effects

As requested this is a short explain for side effects concept.

A side effect is whichever alteration of objects and values derived from the execution of a statement, and which are not the direct expected effect.

int a = 0;
(void)b = ++a;

In the snippet above the void expression lose the direct effect, assigning b, but as side effect increase the value of a.

The only reference, explaining the meaning, in the standard can be found in 5.1.2.3 Program execution:

  1. Accessing a volatile object, modifying an object, modifying a file, or calling a function that does any of those operations are all side effects, which are changes in the state of the execution environment.

    Evaluation of an expression in general includes both value computations and initiation of side effects.

2 of 5
11

void is a type. Per C 2018 6.2.5 19, the type has no values (the set of values it can represent is empty), it is incomplete (its size is unknown), and it cannot be completed (its size cannot be known).

Regarding extern void a;, this does not define an object. It declares an identifier. If a were used in an expression (except as part of a sizeof or _Alignof operator), there would have to be a definition for it somewhere in the program. Since there cannot a definition of void object in strictly conforming C, a cannot be used in an expression. So I think this declaration is allowed in strictly conforming C but is not useful. It might be used in C implementations as an extension that allows getting the address of an object whose type is not known. (For example, define an actual object a in one module, then declare it as extern void a; in another module and use &a there to get its address.)

The declaration of functions with (void) as a parameter list is a kludge. Ideally, () might be used to indicate a function takes no parameters, as is the case in C++. However, due to the history of C, () was used to mean an unspecified parameter list, so something else had to be invented to mean no parameters. So (void) was adopted for that. Thus, (void) is an exception to the rules that would say (int) is for a function taking an int, (double) is for a function taking a double, and so on—(void) is a special case meaning that a function takes no parameters, not that it takes a void.

In foo((void) a), the cast does not make the value “not exist.” It converts a to the type void. The result is an expression of type void. That expression “exists,” but it has no value and cannot be used in an expression, so using it in foo((void) a) results in an error message.

🌐
University of Hawaii
ee.hawaii.edu › ~tep › EE160 › Book › chap5 › subsection2.1.3.1.html
5.3.1 Data Type void
In the function declaration and definition, we have indicated that the function does not return a value by using the data type void to show an empty type, i.e. no value. Similarly, when a function has no formal parameters, the keyword void is used in the function prototype and header to signify that there is no information passed to the function. Here is a simple program using a message printing function which takes a void parameter and returns type void: /* File: msg.c This program introduces data type void.
🌐
Quora
quora.com › What-is-the-difference-between-a-void-and-a-data-type-in-the-programming-language-C
What is the difference between a void and a data type in the programming language C? - Quora
Answer: void means that while it is legal to put a data type there, the programmer does not want to put a data type there. Often this is used for return type. A data type describes some data. void foo(); int bar(); float zz(); are examples of ...
🌐
Codefinity
codefinity.com › courses › v2 › 23515a83-24c1-4300-93aa-17f6fc71455f › e1b0bd58-bbba-4a3c-bff7-0ec91aaf3f59 › 6c63d499-53df-4886-8aaf-a2256d790d48
Learn Void Data Type | Other Data Types and Concepts
Try erasing it in the example. Void pointers (void*) are pointers that do not have a specific data type associated with them. They can point to any type of object, but you must cast them to the appropriate type before using them.
🌐
Quora
quora.com › What-is-void-datatype-in-c
What is void datatype in c? - Quora
Answer (1 of 2): Responding, based on reading your question as > “What is void in C” Every programming language needs a member for referencing objects it uses to execute a piece of logic. And these objects need to be stored in memory During the context of execution.
🌐
Fresh2Refresh
fresh2refresh.com › home › c programming tutorial › c interview questions › what is void in c?
What is void in C? | C Interview Questions | Fresh2Refresh.com
October 15, 2020 - What is void in C? - Void is an empty data type that has no value. We use void data type in functions when we don’t want to return any value etc.
🌐
Reddit
reddit.com › r/c_programming › eli5: void in c
r/C_Programming on Reddit: ELI5: Void in C
March 8, 2024 -

I just began studying C and I cannot, for the life of me, understand void.

I have read and listened to many people say "It does not return a value". Ok? What is a value? Why wouldn't we want to return it? What is the difference between "void main" and "int main"? Can we just use int for everything and ignore void altogether?

In what situations is void used? In what situations is void better? etc. Please help I don't get it at all!

🌐
Quora
quora.com › Is-void-a-data-type
Is 'void' a data type? - Quora
It is a type, but it’s one that generally appears as part of another type—a function type involving [code ]void[/code] or perhaps a pointer ([code ]void*[/code]). This means ...
🌐
C-programming-simple-steps
c-programming-simple-steps.com › what-is-void.html
What is void in C - C Programming
Master C programming in simple steps! Newbie or advanced you can do this in simple steps! Here are the tutorials and examples that will show you how.