What is the usage of “void” in the C language?
In the C language, void is a special type used to represent an empty type. It is typically used in the following scenarios:
- empty
void printHello() {
printf("Hello");
// 无返回值
}
- empty
void printHello(void) {
printf("Hello");
}
- a pointer to an unknown data type
void* ptr;
int num = 10;
ptr = # // 将int类型的指针赋值给void类型的指针
In conclusion, void in C language is a special type used to represent empty type or no return value.