String Split Help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
using namespace std;
int main()
{
 string database[11] = {"elrond", "melkor", "galadriel", "maedhros", "finrod", "cirdan", "artanis", "nerwen", "telerin", "feanor", "celeborn"};
 string emptyPre[11];
 string emptySuf[11];
 string middle[500];

 int counter = 0;

 int dbcounter = 0;
 int precounter = 0;
 int sufcounter = 0;
 int midcounter = 0;

 int substrcounter = 1;
 int substrcounter2 = 2;
 while(counter < 10)
 {
  emptyPre[dbcounter] = database[dbcounter].substr(substrcounter,substrcounter2);
  counter = counter+1;
  dbcounter = dbcounter+1;
  substrcounter = substrcounter+1;
  substrcounter2 = substrcounter2+1;
  cout<<emptyPre[dbcounter]<<"\n";
  cin.get();
 }
 counter = 0;
 dbcounter = 0;
 while(counter < 10)
 {
  substrcounter = database[dbcounter].size();
  substrcounter2 = database[dbcounter].size() - 1;
  emptySuf[dbcounter] = database[dbcounter].substr(substrcounter,substrcounter2);
  counter = counter + 1;
  dbcounter = dbcounter + 1;
  cout<<emptySuf[dbcounter]<<"\n";
  cin.get();
 }
}


I am trying to split an array of strings into substrings to put into several other arrays, however, it is not working.
Topic archived. No new replies allowed.