什么是为size_t用C? [英] What is size_t in C?

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

问题描述

我越来越困惑与为size_t 在C.我知道它是由的sizeof 运算符返回。但它究竟是什么?它是一个数据类型?

I am getting confused with size_t in C. I know that it is returned by the sizeof operator. But what exactly is it? Is it a data type?

让我们说我有一个循环:

Let's say I have a for loop:

for(i = 0; i < some_size; i++)

我应该使用 INT I; 为size_t我;

推荐答案

维基百科

根据1999年的ISO C标准
  (C99),为size_t是无符号整数
  键入的至少16位(见节
  7.17和7.18.3)。

According to the 1999 ISO C standard (C99), size_t is an unsigned integer type of at least 16 bit (see sections 7.17 and 7.18.3).

为size_t是一个无符号的数据类型
  几个C / C ++标准定义,
  例如C99的ISO / IEC 9899标准,
  即在STDDEF.H定义。 1 的它可以
  通过包容性得到进一步进口
  stdlib.h中作为该文件在内部子
  包括STDDEF.H。

size_t is an unsigned data type defined by several C/C++ standards, e.g. the C99 ISO/IEC 9899 standard, that is defined in stddef.h.1 It can be further imported by inclusion of stdlib.h as this file internally sub includes stddef.h.

这类型用来重新present的
  一个对象的大小。库函数
  即采取或返回的大小期望他们
  为类型或者返回类型
  的为size_t。此外,最
  经常使用的编译器为基础的
  运营商的sizeof应评估到
  恒定值,该值是兼容
  为size_t。

This type is used to represent the size of an object. Library functions that take or return sizes expect them to be of type or have the return type of size_t. Further, the most frequently used compiler-based operator sizeof should evaluate to a constant value that is compatible with size_t.

作为一个暗示,为size_t是保证持有任何数组索引类型。

As an implication, size_t is a type guaranteed to hold any array index.

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

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