Is there a split function in some of the more common libraries or would I have to write my own, I need something with the power of the vb split function. Thanks in advance.
Printable View
Is there a split function in some of the more common libraries or would I have to write my own, I need something with the power of the vb split function. Thanks in advance.
Single-char splitter.
Code:TCHAR** VirtualSplitString(TCHAR* pString, TCHAR sep, int& uBound)
{
unsigned long s = 0; unsigned long i = 0;
TCHAR** pArray = (TCHAR**)calloc(strlen(pString), sizeof(TCHAR*));
//allocate empty storage
//the first array
pArray[0] = (TCHAR*)calloc(1024, sizeof(TCHAR));
//separate an array...
while(*pString)
{
//go through the string, find position
if(*pString == sep)
{
i++;
s = 0; //current position
//allocate space for new input
pArray[i] = (TCHAR*)calloc(1024, sizeof(TCHAR));
}
else
{
//get the current character and set it
pArray[i][s] = *pString;
//increase character position
s++;
}
//increase string position
pString++;
}
uBound = ++i;
//return the pArray data type
return pArray;
};
//Frees a buffer
void VirtualFreeHuge(char** pString, int uBound)
{
//free each of the items
for(int i = 0; i <= uBound; i++)
free(pString[i]);
//free the item itself
free(pString);
};
Making good use of STL:
http://www.vbforums.com/showthread.p...hreadid=227148
all the way down.
I tried your method in borland turbo compiler but it didnt work corned, I have vc 6.0 but have to use borland cause its what is at school =(
k got it to work =/