Hi,

I'm updating my code for Snow Leopard and ran into this problem. The
app crashes at this line:

sprintf(str, "%d", val);

where val is a CFIndex. According to the string programming guide here...

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html

...I need to cast my CFIndex to long and replace the %d format
specifier to %ld. I tried that but still got the crash. So I kept
trying with all the format specifiers in the book, declaring my
variable a NSInteger, unsigned int, etc, but no matter what the app
kept crashing. The only that that actually worked was %lx, but then I
get the numbers all wrong. It seems that sprintf only accepts 32-bit
integers. Is this correct? If so, what's the workaround? I'm compiling
for both 10.5 and 10.6. Advice appreciated, thanks.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to