c程序解决方案

c程序
大家好!!! 最近有个问题 一直解决不了 ,希望前辈们帮个忙。
  比如我写了一个从1到100的死循环值i,当输入某个字符时,循环停止并输出i的值,就像抽奖一样 请前辈们帮忙解决一下, 在下不胜感激。

------解决方案--------------------
#include <bios.h> 
#include <stdio.h> 
main()

 int i = 0; 
 while(i++)
 { 
if (bioskey(1)) //有键按下
{
printf("Result = %d\n",i);
}
else //无键按下 
{
if(101 == i)
{
i = 0;
}
}
 } 
}

------解决方案--------------------
C/C++ code
#include <bios.h> 
#include <stdio.h> 
main()
{ 
 int i = 0; 
 while(i++)
 { 
  if ( bioskey(1) && (bioskey(0) == 'P') )  //有键按下 假设指定是 P
  {
    printf("Result = %d\n",i);
  }
  else             //无键按下 
  {
    if(101 == i)
    {
      i = 0;
    }
  }
 } 
}

------解决方案--------------------
我写了一下,你可以参考一下
C/C++ code

bool b_getchar = false;
DWORD   ThreadFunc(LPVOID   lpVoid)   
{    
    int i=0;
    while(!b_getchar)
    {
        ++i;
        if(i>100) i=1;
    }
    printf("%d",i);
    return   0;   
}   

int main(int argc, char **argv)
{
    DWORD   dwThreadID;   

    HANDLE   hThread   =   CreateThread(NULL, //   no   security   attributes     
        0, //   use   default   stack   size     
        (LPTHREAD_START_ROUTINE)   ThreadFunc,     
        (LPVOID)NULL, //   可以通过这个参数传送一个参数的指针到处理函数中   
        0, //   creation   flag     
        &dwThreadID); //   thread   identifier     
    if   (hThread   ==   NULL)     
        return 0;   
    if(getchar()) b_getchar=true;
    int j;//为了使程序停留在屏幕
    scanf("%d",&j);
    return 1;
}