lmem.bak

来自「蓝宇BBPC-SOM2496嵌入式主板 突破DOS内存限制实例代码与函数」· BAK 代码 · 共 32 行

BAK
32
字号
 #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 = (char far *) farcalloc(1, 750000L); /*从堆里分配1个内存块,大小为750,000字节*/
    if(fptr == NULL)
    {
        printf("calloc fail!\n");
    }
    /* copy "Hello" into allocated memory */
    /*
       Note: movedata is used because you 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));

    /* display string (note the F modifier) */
    printf("Far string is: %Fs\n", fptr);

    /* free the memory */
    farfree(fptr);

    return 0;
 }

⌨️ 快捷键说明

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