fork(3) download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5. #include <list>
  6.  
  7. using namespace std;
  8.  
  9. class key
  10. {
  11. public:
  12. int size;
  13. string pat;
  14.  
  15. key( string set_key ) {
  16. pat = set_key;
  17. size = pat.size();
  18. }
  19. };
  20.  
  21. int main()
  22. {
  23. key hl("###");
  24. string str = "###abc#def";
  25. string::iterator itr = str.begin();
  26.  
  27.  
  28. int count = 0;
  29. int i = 0;
  30. while( itr != str.end() ) {
  31. if ( hl.pat[count] == *itr ) ++count;
  32. ++itr;
  33. }
  34.  
  35. string tmp = "<h1>";
  36. itr = str.begin() + count;
  37. while( itr != str.end() ) {
  38. tmp += *itr;
  39. ++itr;
  40. }
  41. const char* end_head = "</h1>";
  42.  
  43. while( *end_head != '\0' ) {
  44. tmp.push_back( *end_head );
  45. ++end_head;
  46. }
  47. cout << tmp << std::endl;
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
<h1>abc#def</h1>