以下代码:
#include<stdlib.h>
#include<stdio.h>
int main (void) {
FILE** f;
if ( (*f = (FILE *)malloc( sizeof(FILE *)) ) == NULL) {
printf("Out of RAM or some other disaster!\n");
return 1;
}
printf("OK!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在Mac OS X 10.8上编译和运行无怨言.但是在Windows 7(使用MinGW编译)上,它会在malloc()上崩溃.为什么这会和/或任何想法阻止它发生?
谢谢!
注意:这显然是一个较大的程序的一部分,但我已经将整个程序减少到上面,并在Mac和PC上尝试了这个代码,并复制了行为.
| 归档时间: |
|
| 查看次数: |
505 次 |
| 最近记录: |