void The void type and generic pointers

void The void type and generic pointers

void is incomplete and valueless, for functions with no result or parameters. void * addresses only objects; dereferencing and void objects are invalid.

CategoryType specifiers
KindKeyword / Statement
C standardC89 / C90

📝 Syntax

void func(void);
void *p;

▶ Example

Edit the C code below and click Run; the server compiles and executes it:

Output:

value = 42

📚 Related Tutorials

❓ FAQ

QAre int main(void) and int main() equivalent?
AIn C89, C99, and C11 prototype semantics, void explicitly specifies no parameters, whereas empty parentheses provide no parameter information. For a main definition, prefer int main(void), the standard no-argument form.
QWhy can't a void pointer be dereferenced or used in pointer arithmetic?
Avoid is an incomplete type with no object size or value type to read. It therefore cannot be dereferenced directly, and standard C does not support void-pointer arithmetic. Convert it to the correct object-pointer type first.
QCan a void function contain a return statement?
AYes, return; can exit the function early, but return with an expression cannot return a value. Reaching the closing brace also returns normally to the caller.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏