Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

Simple c++ exercise to strings and list. The program is explained at: main page

  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <list>
  5. using namespace std;
  6. list<string> or_q;
  7. int main ()
  8. {
  9.   or_q.push_back("IP_");
  10.   or_q.push_back("VHDL_IP_Stack1111");
  11.   if(or_q.empty()) {
  12.     cout<<"error and q is empty" << endl;
  13.     return 1;
  14.   }
  15.   list<string>::iterator it;
  16.   string st;
  17.   fstream infile;
  18.   infile.open ("1", ios::in);
  19.   while(getline(infile,st))
  20.   {
  21.     getline(infile,st);
  22.     for(it=or_q.begin(); it != or_q.end(); it++) {
  23.       string::size_type pos = st.find(*it);
  24.       if(pos != string::npos) {
  25.         cout << pos << " match " << *it << " " << st << endl;
  26.       }
  27.     }
  28.   }
  29.   infile.close();
  30. }

An example for string split into fields: cpp split
  ...


Search This Site


Feedback This Site




new pages on this site