我使用以下代码找出它,但我总是得到1作为答案.有什么不对.谢谢
#include <stdio.h>
#include <stdlib.h>
int main(){
int mult = 0;
int chk =8;
do{
mult+=1;
int *p = (int*)malloc(1024*1024*1024*mult);
if(p==0){
chk =0;
}else{
free(p);
}
}while(chk !=0);
mult = mult -1;
printf("The number of gigs allocated is : %d\n",mult);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
只是为了帮助,我有一个安装了Windows和Linux的64位系统.因此,即使我在64位系统上只获得1 gb的答案,上述逻辑是否正确?
我应该将什么参数传递给wait(),以便它等待所有子进程在继续之前终止