calloc.c

来自「c21Examples.rar」· C语言 代码 · 共 23 行

C
23
字号
/* Demonstrates calloc(). */

#include <stdlib.h>
#include <stdio.h>

int main( void )
{
    unsigned long num;
    int *ptr;

    printf("Enter the number of type int to allocate: ");
    scanf("%ld", &num);

    ptr = (int*)calloc(num, sizeof(long long));

    if (ptr != NULL)
        puts("Memory allocation was successful.");
    else
        puts("Memory allocation failed.");
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?