The size of a void* is a platform dependent value. Typically it's value is 4 or 8 bytes for 32 and 64 bit platforms respectively. If you are getting 2 as the value then your likely running on a 16 bit coding platform (or potentially have a coding error).

Could you post the code you are using and some more information about your environment / operating system?

Answer from JaredPar on Stack Overflow
🌐
Quora
quora.com › What-is-size-of-void-pointer
What is size of void pointer? - Quora
On a 64-bit Ubuntu system with an 8 GB RAM (my system), this size is 8 bytes. This is the size of void pointers, int pointers, and char pointers alike, even long pointers and float pointers.
Discussions

How to find the sizeof whatever a void pointer is pointing to?
There’s no way to accomplish this More on reddit.com
🌐 r/C_Programming
12
0
September 19, 2020
C | find the size of the value a void Pointer is pointing at using sizeof() - Stack Overflow
Im trying to use sizeof() to find the size of the value a void pointer is pointing at, I want to use it to print the value. this code int num = 5; void *voidPtr; voidPtr = # More on stackoverflow.com
🌐 stackoverflow.com
c: size of void* - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. I'm a bit confused with a void* pointer in C. Especially after reading this question: Is the sizeof(some pointer) always equal to four?, where ... More on stackoverflow.com
🌐 stackoverflow.com
how do i find size of an array in a function
You cannot. void f( int arr[] ) is exactly equivalent to void f( int* arr ), meaning you only have a pointer to the array. C-style/raw arrays get implicitly converted into pointers in most situations (commonly called decay). Once you only have a pointer, you have lost all information about the array size, or whether it was an array to begin with. This and the fact that raw arrays do not have value semantics is why they are discouraged in modern C++. The alternatives are: For a fixed size array use std::array For a dynamically sized array, use std::vector For a function parameter when you dont want a copy, use std::span So in your case, your function should be int binary_search( const std::span arr, const int target ) { int start = 0; int end = arr.size(); } On another note: This sizeof(arr)/sizeof(arr[0]) trick is simply never the correct solution. As you have experienced here, it will give you a nonsense answer without any warning. Dont ever use it. Use std::size(arr). That will either work, or it will cause a compilation error if its not possible to determine the size. More on reddit.com
🌐 r/cpp_questions
14
4
January 10, 2023
People also ask

Can you delete a void pointer?
The delete operator in C++ or the free() function in C cannot calculate the proper deallocation size for a void pointer because it lacks type information. You must first convert memory allocated via a void pointer to the relevant data type before using the proper deallocation function (such as delete for C++ objects or free() for dynamically allocated memory) to properly release the memory. What is the size of a void pointer in C?
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › void pointer
Mastering Void Pointers: A Comprehensive Tutorial
What cannot be done on the void pointer?
In C or C++, you cannot directly dereference or execute pointer arithmetic on a void pointer ('void*'). Additionally, until you explicitly convert the data to the correct data type, you cannot access the data it points to. To access the underlying data safely, void pointers must first be cast to the correct type because they lack type information. Can you delete a void pointer?
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › void pointer
Mastering Void Pointers: A Comprehensive Tutorial
🌐
TutorialsPoint
tutorialspoint.com › what-is-the-size-of-void-pointer-in-c-cplusplus
What is the size of void pointer in C/C++ ?
April 11, 2025 - The size of void pointer varies system to system. If the system is 16-bit, size of void pointer is 2 bytes. If the system is 32-bit, size of void pointer is 4 bytes. If the system is 64-bit, size of void pointer is 8 bytes. Finding Size of a Void Poi
🌐
Scaler
scaler.com › home › topics › void pointer in c
Void Pointer in C - Scaler Topics
October 13, 2023 - Void pointers in C are a special ... pointers varies from machine to machine, but in general they are 4 bytes in 32-bit systems and 8 bytes in 64-bit systems...
🌐
Medium
medium.com › @sumeet2703 › why-void-has-no-size-a-deep-dive-into-c-and-c-34104f886c00
Why void Has No Size: A Deep Dive into C and C++ | by Sumeet K | Medium
September 4, 2024 - A void pointer (void *) is a special type of pointer that can point to any data type. However, since the type is not specified, you must cast it to the appropriate type before dereferencing it. ... Here, ptr is a void pointer that can later be cast to an int * to access the integer value. ... When used as a parameter, void specifies that the function does not accept any arguments. This is common in C to explicitly indicate that a function should not take any parameters. ... The sizeof operator is used to determine the size, in bytes, of a data type or variable in C and C++. It is evaluated at compile time and returns the size of the specified type or object.
🌐
upGrad
upgrad.com › home › tutorials › software & tech › void pointer
Mastering Void Pointers: A Comprehensive Tutorial
May 9, 2026 - The size of a void pointer ('void*') in C depends on the platform. It normally has the same size as a system regular pointer, which on a 32-bit system is typically 4 bytes and on a 64-bit system is often 8 bytes.
Find elsewhere
🌐
Scaler
scaler.com › home › topics › what is a void pointer in c++?
What is a Void Pointer in C++? - Scaler Topics
November 4, 2023 - In 16-bit systems, the size of a void pointer is 2 bytes. In a 32-bit system, the size of a void pointer is 4 bytes.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › c ++ programming tutorial › c++ void pointer
C++ Void Pointer | A Quick Glance of C++ Void Pointer with Examples
April 13, 2023 - The void pointer size varied from system to system. If the system configuration is 16 bit then the size of the void pointer is 2 bytes.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Reddit
reddit.com › r/c_programming › how to find the sizeof whatever a void pointer is pointing to?
How to find the sizeof whatever a void pointer is pointing to? : r/C_Programming
September 19, 2020 - C requires explicit type definitions at compile time. There wouldn't be a context in which you can determine the width of data without seeing where it originates.
🌐
Sololearn
sololearn.com › en › Discuss › 2011645 › what-is-the-size-of-void-pointer
What is the size of void pointer? | Sololearn: Learn to code for FREE!
What is that 2 4 0 8 in Relevant Tags? choices for pointer size? did that help identify the problem? did that indicate a language specific? Please see this to understand why tags are important (if you haven't already) https://www.sololearn....
🌐
Unstop
unstop.com › home › blog › void pointer in c explained in detail with code examples
Void Pointer In C Explained In Detail With Code Examples
March 1, 2024 - The platform and the data model, such as 32-bit or 64-bit systems, often determine the size of a pointer. The size of the void pointer on a 16-bit system is 2 bytes.
🌐
Cach3
tutorialspoint.com.cach3.com › what-is-the-size-of-void-pointer-in-c-cplusplus.html
What is the size of void pointer in C/C++ - Tutorials Point - Cach3
November 5, 2018 - The size of void pointer varies system to system. If the system is 16-bit, size of void pointer is 2 bytes. If the system is 32-bit, size of void pointer is 4 bytes.
🌐
Dot Net Tutorials
dotnettutorials.net › home › void pointer in c
Void Pointer in C Language with Examples - Dot Net Tutorials
November 17, 2023 - It is a flexible tool, especially useful in scenarios that require a function to handle different data types or when dealing with raw memory. The Size of the void pointer is 2 bytes.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › void-pointer-c-cpp
void Pointer in C - GeeksforGeeks
2. The C standard doesn't allow pointer arithmetic with void pointers. However, in GNU C it is allowed by considering the size of the void as 1.
Published   November 14, 2025
🌐
PrepBytes
prepbytes.com › home › c programming › void pointer in c
Void Pointer in C
January 8, 2024 - Here, we have printed the size of the void pointer, which comes out to be 8 bytes as we are using a 64-bit computer.
🌐
HackerEarth
hackerearth.com › practice › notes › void-pointer-in-c
void pointer in C | HackerEarth
2) The C standard doesn’t allow pointer arithmetic with void pointers. However, in GNU C it is allowed by considering the size of void is 1.
🌐
PiEmbSysTech
piembsystech.com › home › void pointer in c/c++/embedded c
Void Pointer In C/C++/Embedded C - PiEmbSysTech - Embedded Systems & VLSI Lab
September 15, 2021 - But in the case of a void pointer, we have a limitation in using it. So we cannot use the indirection operator directly. Because a void pointer is not having any data type, so that it creates a problem for the compiler to predict the size of the pointed object at compilation time.
🌐
LinuxQuestions.org
linuxquestions.org › questions › programming-9 › finding-the-size-of-data-in-void-pointer-761588
finding the size of data in void pointer
October 13, 2009 - Hi All, How can I get the size of the content that is stored in the void* pointer?? Below is the sample code... Code: #include