I've been struggling with this function for quite a while and it's starting to drive me insane, So I figured I'd go and ask the never ending supply of knowledge that is this website :P Here's my code, you tell me if you think I'm on the right track.
template<class fIn> char **fileSystem::bufferSeperator(char *buffer1, char **buffer2){
int i = arrayLength(buffer1); //returns the length of array of buffer 1
int j = 0;
int k = 0;
int l[256]; //an array to hold the length of all parts of the strings
int m = 0;
while(j<=i){
m++;
if(buffer1[j] == ' '){ //if the character at j is a space, save length of that array, increment k, and set m = to 0
l[k] = m;
k++;
m = 0;
}
j++;
}
*buffer2 = newchar[k];
for(i = 0; i<=k; i++)
buffer2[i] = new buffer2[l[i]];
j=0;
while(j<=k){
for(i=l;i<=l[i];i++){
buffer2[j][i] = buffer1[i];
}
}
}
if not, let me know how you think I should go about fixing it...i know it's incomplete, but I'm starting to get confused :O
seems alright.
except the buffer2[i] = new buffer2[l[i]]. I guess you meant char[li[i]].
and also the whole part where you copy from one array to other is a little broken
j is never incremented
i should start from 0
if buffer2[j][i] = buffer1[i]; every line in 2d array will be the beginning of the 1d array
you should make another variable, that is incremented whenever i is, but isn't reset on line 21
thanks, yea thats what i meant on line 18...it's been 12 hours of staring at code, which CANNOT be healthy, So I'm going to bed and fixing it when I wake up :P Thanks again.