View Single Post
Old Apr 28th, 2005, 2:12 PM   #19
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
That's what I'm saying - you need pointers to get it into the array:
// loop through and count the number of spaces:
int count = 0;
for (int i = 0; note[i]; i++)
{
    if (note[i] == 0x20)
    {
        count++;
    }
}

// declare a new array with that many items plus one
string *words = new string [count + 1];

int lastSpace = -1;
count = 0;

for (int i = 0; note[i]; i++)
{
    if ((note[i] == 0x20))
    {
        *(words + count) = note.substr(lastSpace + 1, i - lastCount + 1);
        count++;
    }
}
*(words + count) = note.substr(lastSpace + 1, note.length());
That'll load 'em into an array (hopefully - it hasn't been tested).
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote