关于size_t [英] regarding size_t

查看:121
本文介绍了关于size_t的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在

stdlib.h中查看malloc()函数的函数原型,我发现它是,


void * malloc(size_t size);


那么size_t是int的预定义typedef吗?


提前致谢。

Hi Everyone,

I was looking at the function prototype of malloc() function in
stdlib.h and i found that to be,

void *malloc(size_t size);

so what is size_t is it a pre-defined typedef to int?

Thanks in advance.

推荐答案

2007年1月13日01:39:22 -0800, sa ***** @ yahoo.co.in 写道:
On 13 Jan 2007 01:39:22 -0800, sa*****@yahoo.co.in wrote:

>大家好,


我在
stdlib.h中查看malloc()函数的函数原型,我发现它是,

void * malloc(size_t size);


那么size_t是int的预定义typedef吗?

提前致谢。
>Hi Everyone,

I was looking at the function prototype of malloc() function in
stdlib.h and i found that to be,

void *malloc(size_t size);

so what is size_t is it a pre-defined typedef to int?

Thanks in advance.



size_t是一个预定义类型,根据C标准,它是

"结果的无符号整数类型of sizeof operator。

类型size_t是无符号的,它不能被定义为类型

int,必须签名。


- -

jay

size_t is a pre-defined type, which, according to the C Standard, is
"the unsigned integral type of the result of the sizeof operator". The
type size_t is unsigned, and it cannot possibly be defined as type
int, which must be signed.

--
jay


sam _... @ yahoo.co.in写道:
sam_...@yahoo.co.in wrote:

大家好,


我在

stdlib.h中查看malloc()函数的函数原型,我发现它是,


void * malloc(size_t size);


那么size_t是int的预定义typedef吗?
Hi Everyone,

I was looking at the function prototype of malloc() function in
stdlib.h and i found that to be,

void *malloc(size_t size);

so what is size_t is it a pre-defined typedef to int?



size_t是一个无符号整数类型的typedef,意味着能够存储对象大小的
。它没有预先定义:它在

中定义了几个标准标题,但是如果你不包含它们中的任何一个,

你是免费的在你自己的代码中使用size_t作为普通标识符。

它具有哪种特定类型取决于实现,并且它最好不要假设比你更多的东西需要了解它。

size_t is a typedef for some unsigned integer type meant to be capable
of storing the size of objects. It is not pre-defined: it is defined in
several of the standard headers, but if you don''t include any of them,
you''re free to use size_t as an ordinary identifier in your own code.
Which specific type it has depends on the implementation, and it would
be best not to assume anything more than you need to about it.


Harald van D?k写道:
Harald van D?k wrote:

sam_ .. 。@ yahoo.co.in写道:
sam_...@yahoo.co.in wrote:

>我在
stdlib.h中看了malloc()函数的函数原型,我找到了那就是,

void * malloc(size_t size);

那么size_t是int的预定义typedef吗?
>I was looking at the function prototype of malloc() function in
stdlib.h and i found that to be,

void *malloc(size_t size);

so what is size_t is it a pre-defined typedef to int?



size_t是某个无符号整数类型的typedef,意思是

能够存储对象的大小。它没有预定义:它在几个标准标题中定义了
,但是如果你不是b $ b包括其中任何标题,你就是免费的在您自己的代码中使用size_t作为普通的

标识符。它的具体类型取决于实现的
,最好不要假设

比你需要的更多。


size_t is a typedef for some unsigned integer type meant to be
capable of storing the size of objects. It is not pre-defined: it
is defined in several of the standard headers, but if you don''t
include any of them, you''re free to use size_t as an ordinary
identifier in your own code. Which specific type it has depends
on the implementation, and it would be best not to assume
anything more than you need to about it.



不,您不能将其用于其他目的。在某些实现中,你可以使用它获得

。您无法使用任何标准标题中定义的任何内容。


-

最令人惊叹的成就计算机软件行业

是它继续取消计算机硬件行业所取得的稳定和惊人的b $ b增长...... - Petroski

No, you are not free to use it for other purposes. You MAY get
away with it on some implementations. You are not free to use
anything defined in any standard headers.

--
"The most amazing achievement of the computer software industry
is its continuing cancellation of the steady and staggering
gains made by the computer hardware industry..." - Petroski


这篇关于关于size_t的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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