#include <stdlib.h>
void *calloc(size_t number_of_elements, size_t element_size);
#include <stdio.h>
#include <stdlib.h>
struct test {
int a[10];
char b[20];
};
int main()
{
struct test *ptr = calloc(sizeof(struct test), 10);;
printf ("%x\n", ptr);
ptr += 1;
printf ("%x\n", ptr);
ptr -= 1; //调整内存指针到原分配位置
free(ptr); //释放分配的内存
return 0;
}
./calloc
804b008
804b044
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |