读书人

多线程的C程序调用process.h不出结果

发布时间: 2012-10-15 09:45:24 作者: rapoo

多线程的C程序,调用process.h不出结果

C/C++ code
#include<stdio.h>#include<process.h>#include<stdlib.h>using namespace std;int a[100];void f1(void* p){    for(int i=0;i<100;++i){        a[i]=i;        //system("pause");    }}void f2(void* p){    for(int i=0;i<100;++i){        printf("%2d",a[i]);        //system("pause");    }}int main(){    _beginthread(f1,0,0);    _beginthread(f2,0,0);    return 0;}

为啥不出结果啊?
我用的codeblock,关掉了-mwindows选项

[解决办法]
C/C++ code
_beginthread(f1,0,0);_beginthread(f2,0,0); 

读书人网 >C语言

热点推荐