小编Sli*_*ore的帖子

为什么我的 DOS 程序在我 memset 一个 64000 个 int 数组后崩溃了?

memset我在 Turbo C 中遇到了一个大的 for 循环问题。

当代码开始崩溃时,我正在 Virtual Box 上的 MS-DOS 6.22 上使用 Turbo C++ 3.00 编写一个基于模式 13h 的小型图形库。

我知道 Turbo C 确实已经过时了,但我想在类似 DOS 的系统上尝试旧式编码。

这是我的代码:

#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <dos.h>

int main(void) {
  int *buf;
  unsigned int i;

  _AH = 0x0;
  _AL = 0x13;
  geninterrupt(0x10);

  buf = malloc(sizeof(int)*64000);
  memset(buf,15,64000); //can't figure out why memset does not work properly...

  for (i=0;i< (unsigned int)64000;i++){
    buf[i] = 15; //trying to forcely set each byte to 0xf... …
Run Code Online (Sandbox Code Playgroud)

c dos turbo-c x86-16

1
推荐指数
1
解决办法
212
查看次数

标签 统计

c ×1

dos ×1

turbo-c ×1

x86-16 ×1