yolo.c中的函数定义

1. calloc()

2. sizeof()

In the programming languages C and C++, the unary operator sizeof generates the size of a variable or datatype, measured in the number of char size storage units required for the type. As such, the construct sizeof (char) is guaranteed to be 1. The actual number of bits of type char is specified by the preprocessor macro CHAR_BIT, defined in the include file limits.h. On most modern systems this is eight bits. The result has an unsigned integral type that is usually denoted by size_t.

Example:

In many programs, it is useful to know the size of a particular datatype. Though for any given implementation of C or C++ the size of a particular datatype is constant, the sizes of even primitive types in C and C++ are implementation-defined. This is important when allocating a block of memory of the appropriate size.

int *pointer = malloc(10 * sizeof (int));

In this example, malloc allocates memory and returns a pointer to the memory block. The size of the block allocated is equal to the number of bytes for a single object of type int multiplied by 10, ensuring enough space for ten integers.

The sizeof operator is used to determine the amount of space a designated datatype would occupy in memory. To use sizeof, the keyword “sizeof” is followed by a type name or an expression (which may be merely a variable name). If a type name is used, it must always be enclosed in parentheses, whereas expressions can be specified with or without parentheses. A sizeof expression results in a value equal to the size in bytes of the datatype or expression (with datatypes, sizeof evaluates to the size of the memory representation for an object of the specified datatype; for expressions it evaluates to the representation size for the type that would result from evaluation of the expression, which however is not evaluated). For example, since sizeof(char) is defined to be 1 and assuming the integer type is four bytes long, the following code prints 1,4:

/* the following code fragment illustrates the use of sizeof
 * with variables and expressions (no parentheses needed),
 * and with type names (parentheses needed)
 */

char c;

printf("%zu,%zu\n", sizeof c, sizeof (int));

3. srand()

4. strncpy()

5. fflush() fflush()

6. fgets()

7. strtok()

8. snprintf()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值