zoukankan      html  css  js  c++  java
  • <C++>查询

    怎样从文本1中找出乱码词,在文本2中找出对应语句,在文本3中输出来:

    先建Win32控制台应用程序,再引入头文件:

    #include <iostream>

    #include <fstream>

    #include <string>

    #include <vector>

    using namespace std;

    int _tmain(int argc, _TCHAR* argv[])

    {

      vector<string> vstr;

      fstream file1("d:\test1.txt");

      fstream file2("d:\test2.txt");

      fstream file3("d:\test3.txt");

      while(!file1.eof())

      {

        char buf[MAX_PATH];

        file1.getline(buf,sizeof(buf));

        string getStr = string((const char*)buf);

        if(string::npos != getStr.find('?',0))

        {

          string str = getStr.substr(0,getStr.find(' ',0));

          vstr.push_back(str);
        }  

      }  

      while(!file2.eof())

      {

        char buf[MAX_PATH];

        file2.getline(buf1,sizeof(buf1));

        string getStr1 = string((const char*)buf1);

        for(int i=0; i < vstr.size();i++)

        {

          if(string::npos != getStr1.find(vstr[i],0))

          {

            file3<<getStr1<<endl;

            break;

          }
        }

      }  

      file1.close();

      file2.close();

      file3.close();

      return 0;

    }

  • 相关阅读:
    pl/sql 导入csv到oracle时乱码问题
    mybatis if判断两个值是否相等存在的坑啊
    mybatis #与$占位符的区别
    NPM使用前设置和升级
    AWS ec2的ubuntu14.04上安装git服务
    Apache性能优化
    i5+GT730+B85安装OSX10.10.5 (Yosemite Install(14F27).cdr)
    IE的css hack
    sourcetree(mac)设置代理
    webpack配置的说明
  • 原文地址:https://www.cnblogs.com/virgil/p/3811124.html
Copyright © 2011-2022 走看看