• 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
Bug in NSString stringWithFormat (or sprintf)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in NSString stringWithFormat (or sprintf)?


  • Subject: Bug in NSString stringWithFormat (or sprintf)?
  • From: Christian Mike <email@hidden>
  • Date: Mon, 20 Aug 2001 16:21:47 -0500

I may have found a bug in NSString stringWithFormat. This may or may not be
a bug and it may or may not be known.

If I create a string:

NSString *stringTemp = [NSString
stringWithFormat:@"%.4s","abcdefgh"];

stringTemp will now contain the string "abcdefgh". I was expecting just
"abcd".

In any other C compiler that I have worked with, if you specify a precision
for a character string in a format specifier, this precision says output AT
MOST "n" characters, but stop if you encounter a NULL byte. For this example
(and I got the same results with sprintf), the precision digit appears to be
ignored on the string specifier, and the transfer continues until a NULL
byte is encountered.

Is this a bug?

Michael Christian
Thomson multimedia Inc.


  • Prev by Date: Turning off line wrapping in NSTextView
  • Next by Date: Re: Clear as Mud
  • Previous by thread: Re: Turning off line wrapping in NSTextView
  • Next by thread: Re: Bug in NSString stringWithFormat (or sprintf)?
  • Index(es):
    • Date
    • Thread