Nigel Grant wrote:
[NG] I cant break up the line by replacing "|" with a "0", I need to
put both of the seperated fields into a structure & this cannot have
"0" at the end of either field.
All strings in C always end with a zero.
If you do this:
const Char *mystring = "abc";
then it is equivalent to this:
const Char mystring[] = { 'a', 'b', 'c', 0 };
Or, another way to say it is, the following code will print zero:
const Char *mystring = "abc";
printf ("%d\n", (int) mystring[3]);
Of course it would have to be run on a device that supports printf(),
which the Palm doesn't directly support. The reason it prints zero
is that when you write "abc", this creates a string with a null
terminator.
If you are having trouble putting these into a structure, you probably
need to do one of two things:
(1) If your struct contains just a pointer, then copy the strings
into their own memory area like this:
Char *namecopy = MemPtrNew (1 + StrLen (firststring));
if (namecopy == NULL) { /* handle the error */ }
StrCopy (namecopy, firststring);
(2) If your struct contains an array of characters, then copy
the strings into the array in the struct like this:
StrCopy (mystruct.name, firststring);
In this case, you also need to somehow make sure that the
array within your struct is large enough to hold the string!
Hope that helps.
- Logan
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/