|
-
Jan 27th, 2003, 08:05 PM
#1
Thread Starter
Fanatic Member
Split Function
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.
-
Jan 28th, 2003, 12:20 AM
#2
Hyperactive Member
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);
};
-
Jan 28th, 2003, 07:41 AM
#3
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 28th, 2003, 04:42 PM
#4
Thread Starter
Fanatic Member
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 =(
-
Jan 28th, 2003, 06:09 PM
#5
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|