zoukankan      html  css  js  c++  java
  • 遍历文件下所有文件

     1 _finddata_t file;
     2 
     3     char* szFilePack="F:\RTMFP\measurement data\ME4\recursive2\lossbyte\*.txt";
     4     long lf;
     5     if ((lf=_findfirst(szFilePack,&file))==-1)//==优先级较高所以要加括号,找到文件夹下面第一个符合的文件
     6     {
     7         cout<<"cannot find file"<<endl;
     8     }
     9     else
    10     {
    11         cout<<"1111 "<<file.name<<endl;
    12         ifstream infile("F:\RTMFP\measurement data\ME4\recursive2\lossbyte\"+string(file.name));
    13         if (infile==0)
    14             cout<<"infile open failed! "<<file.name<<endl;
    15         else
    16         {
    17             //cout<<"1111 "<<file.name<<endl;
    18             int lossb=0;
    19             string line,word;
    20             istringstream linestream;
    21             while(getline(infile,line))
    22             {
    23                 linestream=istringstream(line);
    24                 linestream>>word;
    25                 linestream>>word;
    26                 linestream>>word;
    27                 lossb+=atoi(word.c_str());
    28             }
    29             lossbytes[file.name]=lossb;
    30         //    cout<<_findnext(lf,&file)<<endl;
    31         
    32             while(_findnext(lf,&file)==0)
    33             {
    34                 cout<<"1111 "<<file.name<<endl;
    35                 //cin>>x;
    36                 int lossb=0;
    37                 string line,word;
    38                 ifstream infile("F:\RTMFP\measurement data\ME4\recursive2\lossbyte\"+string(file.name));
    39                 istringstream linestream;
    40                 while(getline(infile,line))
    41                 {
    42                     linestream=istringstream(line);
    43                     linestream>>word;
    44                     linestream>>word;
    45                     linestream>>word;
    46                     lossb+=atoi(word.c_str());
    47                 }
    48                 lossbytes[file.name]=lossb;
    49             }
    50         }
    51     }
  • 相关阅读:
    Servlet
    Web服务器和Tomcat
    DOM文档对象模型
    JavaScript总结
    CSS总结
    商城——购物车模块
    用户注册登录认证模块
    P2P技术之STUN、TURN、ICE详解
    P2P中的NAT穿越(打洞)方案详解
    NAT技术详解
  • 原文地址:https://www.cnblogs.com/xaf-dfg/p/3875728.html
Copyright © 2011-2022 走看看