void 是 C 中的数据类型吗? [英] Is void a data type in C?

查看:28
本文介绍了void 是 C 中的数据类型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void 是 C 编程语言中的一种数据类型吗?如果是这样,它可以存储什么类型的值?如果我们有intfloatchar等来存储值,为什么还需要void?以及虚空的范围是多少?

Is void a data type in the C programming language? If so, what type of values can it store? If we have int, float, char, etc., to store values, why is void needed? And what is the range of void?

推荐答案

Void 被认为是一种数据类型(用于组织目的),但它基本上是一个关键字,用作放置数据类型的占位符,以表示没有数据".

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.

这篇关于void 是 C 中的数据类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆