Hi,

your are right the code is ok. BTW i changed somethings, but the result is
the same.

I pass the constructed char** to the LstNewList-function to build up an new
List in the UI.
This works fine too, but when i then scroll to the end of the list,
there appears an item with not entry, and i get the following error!

>Read can not performed to memory at position "0x0e000000"<

Perhaps there is still a problem with the passed char**. It looks like there
are to much items in the list.

Any suggestions, why this happens?

Thanks,
Peter


"Caspar Heiden, vd" <[EMAIL PROTECTED]> schrieb im
Newsbeitrag news:[EMAIL PROTECTED]
Hi,

I quickly glanced over your code, but it looks OK to me. What exactly is
your problem / question?

Good luck,

Caspar

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Pit
Sent: Thursday, April 08, 2004 6:03 PM
To: Palm Developer Forum
Subject: strin tokenizing and char **

Hi,
i want  to store the following string, separated by '/' in to the pointer
temp!

char* test = "1/2/3/Peter/sdlk
fslkdj/gowrsdn/sfgmbdg,m.,.-f�sdfg/sdfgfdglk";
char** temp;

Therfore, i think i have to allocate memory!
char** temp, is a pointer to pointers to strings (char *), am i rigth?

So i allocated memory for temp and also for the entrys of temp (temp[0]).
Because i dont know how many string i store in temp, i count the '/' in the
test - string and allocate then the memory:
Is this correct?

char separator = '/';
int i,k = 0;
for (i = 0; i <= StrLen(test); i++) {
     if (separator == test[i])
      k++;
}
temp = MemPtrNew ((k+1) * 4);

Then i call the Tokenizer-function, i think there works anything fine.
But i am not absolutly sure.

Tokenizer (test, temp);

static void Tokenizer (char* input, char** returnV) {
    int i, j = 0, k = 0;
    char extracted[255];
     char separator = '/';

    for (i = 0; i <= StrLen(input); i++)
    {
     if (separator == input[i] || i == StrLen(input) ) // terminate if '/'
found or end of string reached
     {
      extracted[j] = '\0'; // terminate extracted String
      returnV[k] = MemPtrNew (sizeof(char) * StrLen (extracted));  //
Allocate memory for new String
      StrCopy (returnV[k], extracted);  // Copy String into allocated memory

      j = 0; // skip to start of extracted-string
      i++; // skip '/'
      k++; // skip one position in returnV-Array
     }
     extracted[j] = input[i];
     j++;
 }

}



-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to