zoukankan      html  css  js  c++  java
  • VC查找文件特定位置的记录方法

                  FILE *pFile = fopen(fileDlg.GetFileName (),"r");

                  char array[1024];

                  memset(array,0,1024);

                  while(!feof(pFile))

                  {

                         fgets(array, 1024, pFile);   //获取一行的信息

                         CString str;

                         str.Format ("%s",array);

                         int arr[5];

                         memset(arr,0, 5);

                                             

                         tradingname = filename;

                        

                         int ipos = 0;

                         for (int i=0; i<5; i++)

                         {

                                ipos = str.Find (",", ipos+1);

                                arr[i] = ipos;

                         }                  

                         tradingday = str.Mid (0,arr[0]);

                         tradingday = TransForm(tradingday);

                         openprice = str.Mid (arr[0]+1,arr[1]-arr[0]-1);

                         highestprice = str.Mid (arr[1]+1, arr[2]-arr[1]-1);

                         lowestprice = str.Mid (arr[2]+1, arr[3]-arr[2]-1);

                        

                         closeprice = str.Mid (arr[3]+1, arr[4]-arr[3]-1);

                        

                         volume = str.Mid (arr[4]+1);

                        

    }

    CString CDataMaintenanceDlg::TransForm(CString str)

    {

           CString strTemp, str1,str2,str3;

          

           int arr[2];

           memset(arr,0, 2);         

           int ipos = 0;

                               

           for (int i=0; i<2; i++)

           {

                  ipos = str.Find ("/", ipos+1);

                  arr[i] = ipos;

           }

                               

           str1 = str.Mid (0, arr[0]);

          

           str2 = str.Mid (arr[0]+1, arr[1]-arr[0]-1);

          

           str3 = str.Mid (arr[1]+1, arr[2]-arr[1]-1);

          

           return strTemp=str3+str1+str2;

                               

    }

  • 相关阅读:
    HDU6256 Master of Phi (狄利克雷卷积、欧拉函数)
    POJ2689 Prime Distance
    演练5-4:Contoso大学校园管理系统4
    Week7(10月24日)
    演练5-3:Contoso大学校园管理系统3
    Week7(10月21日)
    演练5-2:Contoso大学校园管理2
    Week6(10月17日):周末别忘记运动
    演练5-1:Contoso大学校园管理1
    Week6(10月14日)
  • 原文地址:https://www.cnblogs.com/aimenfeifei/p/3281842.html
Copyright © 2011-2022 走看看