#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
int i;
int *str = NULL;
str = (int*)calloc(10, sizeof(int));
if(str==NULL)
{
printf("calloc error!\n");
return -1;
}
printf("start addr: %p\n", str);
printf("Memory contents:");
for(i=0;i<10;i++)
{
printf("%d ",str[i]);
}
printf("\n");
free(str);
return 0;
}
时间: 2024-10-11 06:20:58