• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
sprintf and 64-bit integers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sprintf and 64-bit integers


  • Subject: sprintf and 64-bit integers
  • From: "email@hidden" <email@hidden>
  • Date: Sun, 13 Sep 2009 19:59:17 +0200

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: sprintf and 64-bit integers
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Bug: CalendarStore framework adding events with alarms with email address.
  • Next by Date: Re: sprintf and 64-bit integers
  • Previous by thread: Bug: CalendarStore framework adding events with alarms with email address.
  • Next by thread: Re: sprintf and 64-bit integers
  • Index(es):
    • Date
    • Thread