Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
search.cpp
Go to the documentation of this file.
1
29#include <algorithm>
30#include <list>
31#include <iostream>
32
33int main ()
34{
35#ifndef _RWSTD_NO_NAMESPACE
36 using namespace std;
37#endif
38
39 //
40 // Initialize a list sequence and subsequence with characters.
41 //
42 char seq[40] = "Here's a string with a substring in it";
43 char subseq[10] = "substring";
44 list<char,allocator<char> > sequence(seq, seq+38);
45 list<char,allocator<char> > subseqnc(subseq, subseq+9);
46 //
47 // Print out the original sequence.
48 //
49 cout << endl << "The subsequence, " << subseq << ", was found at the ";
50 cout << endl << "location identified by a '*'" << endl << " ";
51 //
52 // Create an iterator to identify the location of
53 // subsequence within sequence.
54 //
55 list<char,allocator<char> >::iterator place;
56 //
57 // Do search.
58 //
59 place = search(sequence.begin(), sequence.end(),
60 subseqnc.begin(), subseqnc.end());
61 //
62 // Identify result by marking first character with a '*'.
63 //
64 *place = '*';
65 //
66 // Output sequence to display result.
67 //
68 for (list<char,allocator<char> >::iterator i = sequence.begin(); i != sequence.end(); i++)
69 cout << *i;
70 cout << endl;
71
72 return 0;
73}
#define i
Definition 17.names.cpp:126
Definition json.h:5363
int main()
Definition search.cpp:33