PICKLIST.CPP
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:1k
源码类别:

游戏

开发平台:

Visual C++

  1. // (C) Copyright 1996 by Anthony J. Carin.  All Rights Reserved.
  2. #include "stdafx.h"
  3. #include "levels.h"
  4. const int MAXLIST = 100;
  5. CString& picklist(float pick, CString& file)
  6. {
  7.     static CString ret;
  8.     CString list[MAXLIST];
  9.     FILE *fp;
  10.     char tmpbuf[300];
  11.     int i;
  12.     fp = fopen(file, "r");
  13.     if (fp <= 0)
  14.     {
  15.         ret = "";
  16.         return ret;
  17.     }
  18.     for (i = 0; i < MAXLIST; i++)
  19.     {
  20.         fscanf(fp, "%s", tmpbuf);
  21.         list[i] = tmpbuf;
  22.         if (feof(fp))
  23.             break;
  24.     }
  25.     fclose(fp);
  26.     i++;
  27.     i = (int) (i * pick);
  28.     while (i >= 0 && list[i].IsEmpty())
  29.         i--;
  30.     if (i < 0)
  31.         ret = "";
  32.     else
  33.         ret = list[i];
  34.     return ret;
  35. }