• 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;

                               

    }

  • 相关阅读:
    医学影像
    阿里云九卿 大数据产业化
    陈海青 阿里
    店铺高频问题主动生成知识点机器 大脑+人脑 知识库
    数据总线和流计算在城市大脑中的应用
    无推荐不APP
    ww
    业务架构
    jd算法大赛 一个user_id只需映射到一个sku_id, 但是一个sku_id能否映射到多个user_id
    短URL DH 密钥交换算法
  • 原文地址:https://www.cnblogs.com/aimenfeifei/p/3281842.html
Copyright © 2020-2023  润新知