At 01:25 PM 4/25/2005, you wrote:
Ben,
    when i looked at the values of what sizeof() and strlen() returned on
was 34 the other was 33 respectively (0x0022, 0x0021).

Oops...

"This is a test" isn't typed as const char *, but instead as const char[15], which means the sizeof operator returns 15 -- the 14 characters of text plus a trailing NUL (0) character that terminates the string. However, if you wrote

const char *str = "This is a test";

Then sizeof(str) would be 4. sizeof isn't generally useful for determining the length of a string, since it only deals with information it knows at compile-time.

-- Ben Combee, Senior Software Engineer, palmOne, Inc.
   "Combee on Palm OS" weblog: http://palmos.combee.net/
   Developer Forum Archives:   http://news.palmos.com/read/all_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