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)