Em đọc trong sách thì có ví dụ minh họa này em không hiểu gì cả.Nhờ mọi người giải thích giúp em với.
#define ALLOCSIZE 10000 /* size of available space */
static char allocbuf[ALLOCSIZE]; /* storage for alloc */
static char *allocp = allocbuf; /* next free position */
char *alloc(int n) /* return pointer to n characters */
{
if (allocbuf + ALLOCSIZE - allocp >= n) /* it fits */
{
allocp += n;
return allocp - n; /* old p */
}
else /* not enough room */
return 0;
}
void afree(char *p) /* free storage pointed to by p */
{
if (p >= allocbuf && p < allocbuf + ALLOCSIZE)
allocp = p;
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?