2026年11月2日 · 今日 0 帖 · 会员 6.1万 · 主题 17.4万
登录 · 注册 · 游客,欢迎随便逛逛
返回版块
只看作者:洞房 查看全部
1000
Lv9有为九子能等级图标
勋章勋章勋章勋章勋章
帖子
9.3万
回复
2,089
积分
60.3万
注册
2006-12-06
[怀旧国机]

函数名: farmalloc

[复制链接]
查看 143 回复 0
楼主 发表于 | 查看全部
1 人收藏

函数名: farmalloc

功 能: 从远堆中分配存储块

用 法: void far *farmalloc(unsigned long size);

程序例:

#include <stdio.h>

#include <alloc.h>

#include <string.h>

#include <dos.h>

int main(void)

{

char far *fptr;

char *str = “Hello“;

/* allocate memory for the far pointer */

fptr = farmalloc(10);

/* copy “Hello“ into allocated memory */

/*

Note: movedata is used because we might

be in a small data model, in which case

a normal string copy routine can not be

used since it assumes the pointer size

is near.

*/

movedata(FP_SEG(str), FP_OFF(str),

FP_SEG(fptr), FP_OFF(fptr),

strlen(str));

/* * string (note the F modifier) */

printf(“Far string is: %Fs\n“, fptr);

/* free the memory */

farfree(fptr);

return 0;

}

登录回复

登录后可以回复这个帖子。旧账号可使用原密码登录。

登录 注册新号
← 返回版块