"Sam Trimble" <[EMAIL PROTECTED]> writes:
> My code goes somthing like this....
>
> #define AppFileCreator 'test'
> #define PreferenceID 0x00
> #define Version 1
> Char somechar[25] = "";
>
> static void SavePrefs()
> {
> DBStruct prefs;
>
> StrCopy(somechar, "SomePreferenceText");
> prefs.charpref = somechar;
> PrefSetAppPreferences(AppFileCreator, PreferenceID, Version, &prefs,
> sizeof(DBStruct), true);
> }
This won't work correctly. In fact, it's wrong in a lot of serious
ways. What you are storing in the prefs database is the memory address
of the somechar array, *not* the contents of the somechar array.
Fortunately for you, that memory address doesn't usually change between
program runs, so when you retrieved that address in a subsequent run, it
was still valid and the program didn't crash. It just didn't behave as
you expected.
You need to get a C book and study up on the differences between Char*
and Char[], and learn when it's appropriate to use one or the other.
Hint: PrefSetAppPreferences does a byte-for-byte copy of the struct into
the prefs database, so think about what the bytes in the struct contain.
--
Dave Carrigan ([EMAIL PROTECTED]) | Yow! --- I have seen the FUN ---
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-DNS |
Seattle, WA, USA |
http://www.rudedog.org/ |
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/