--- bill <[EMAIL PROTECTED]> wrote:
> Here is some sample code, that if I could get some help on,
> it might help with the other problem I mentioned earlier.
It needs a lot of help. :(
I don't remember what the other problem was, but perhaps it will...
> void Seperator (char* Data[], char* text)
> {
> UInt16 index=0, letterCount=0, row=0;
> char tempData[255];
> for (int i=0; i<strlen(text); i++)
There is no strlen() function in the Palm API. That, coupled with the
fact that you are using char everywhere instead of Char or WChar, leads
me to suspect that you aren't running this on any Palm Powered device.
> if (text[i]==' ')
> {
> tempData[letterCount]='\0';
> Data[row++]=tempData;
tempData won't exist after this function executes, so why are you
trying to copy its address to Data[row]? You'd get better results
using StrCopy() (if Data[] had been allocated some space, that is).
> letterCount=0;
> }
> else
> tempData[letterCount++]=text[i];
> }
>
> //------------------------------------------------------------
> void test()
> {
> char* Title[3];
This allocates space for 3 pointers. It does not allocate any space to
hold the strings.
> char* Desc[3];
Ditto, except you don't use this in the following code so it doesn't
matter.
> char* Titles="book1 book2 book3";
> char* Description="fact1 fact2 fact3";
> Seperator (Title, Titles);
Here you are passing in a pointer to three pointers that don't point to
anything useful, and a pointer to a string (char *).
> int i=0;
> while (Title[i])
What do you expect to happen when i==3 ? You will be trying to access
memory beyond the bounds of the array.
> Print(Title[i++]);
There is no Print function in the Palm API -- is this your own
function?
> }
>
> I want the Title[] to be:
> book1
> book2
> book3
>
> it seperates it fine in seperator, but there is nothing int Title[]
> when it returns.
You never allocated any space to hold the strings.
> I have been reading on this from numerous books and have gotten more
> confused,
Perhaps a little more reading will help. Start with a book on C
programming. Almost all of them will show you how to create arrays of
characters (strings) and arrays of arrays of characters (or pointers to
pointers to characters if you like) and will show you how to pass them
into functions and how to get something back from the function. C
passes everything by value, so a function can't change anything unless
it receives a pointer to that thing. Then it can't change the pointer,
but it can change what it points to.
<philosophy>
Veering philosophical on a Saturday night... This last point is both
the greatest strength and the greatest weakness of C.
</philosophy>
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/