Is out of scope....
what is it initilized to.. What happens if the user passes this after initilizin this to say 1000 it will screw up the below part
for (int nSString = 0; nSString < nTokenCount; nSString++)
and the way it tokenizes dosent seem right... if the input it
"how are you" the output is
"how are you"
but maybe thats what you wanted...
what happens to this.. where is this memory freed... and this cannot be freed outside the function because there is no visibility from outside...
char* pMyInput = new char[nInputLength];
and where is your custom StringCopy function...
I am sure that might have some memory leaks...
andwhen you allocate memory using new.. what happens if the system run of memory and returns NULL instead...
and what happens if I do not want to tokenize the string based on space but on tab... your function delibrately introduces space and considers all spaces as delimeters
now you are checking nCount+1 which at the end of the for loop will be nInputLength so you are accessing
for (int nCount = 0; nCount < nInputLength; nCount++) //count number of tokens (spaces)
if (pMyInput[nCount] == ' ' && pMyInput[nCount+1] != ' ')
pMyInput[nCount+1] which at the end is actually pMyInput[nInputLength] whose memory space does not belong to your function... this might cause the program to crash in the worst case...
what happens if the string contained no delimeter character to tokenize... you still allocate memory making it inefficient..
pSuperString = new char*[nTokenCount]; //number of tokens (+1) = number of strings
and not to talk about the inefficiency of the algorithm.. we will keep that for another session after you correct your code