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

Re: Bug in NSString stringWithFormat (or sprintf)?


  • Subject: Re: Bug in NSString stringWithFormat (or sprintf)?
  • From: Ondra Cada <email@hidden>
  • Date: Tue, 21 Aug 2001 13:06:28 +0200

Chris,

>>>>>> Chris Boot (CB) wrote at Tue, 21 Aug 2001 12:15:53 +0200:
CB> I dunno, but you might try "%4s" rather than "%.4s"...

Nope. The before-point number would only _expand_ the string length, not
shorten it. Why don't you learn the printf behaviour in some reference?

Incidentally, in my MOSXS1 it works properly:

58 /tmp\> cat qq.m
#import <Foundation/Foundation.h>
void main() {
id pool=[NSAutoreleasePool new];
printf("[%5s] [%5s] [%.5s] [%.5s]\n","abc","abcdefghij","abc","abcdefghij");
printf([[NSString stringWithFormat:@"[%5s] [%5s] [%.5s]
[%.5s]\n","abc","abcdefghij","abc","abcdefghij"] cString]);
[pool release];
}
59 /tmp\> cc -Wall -framework Foundation qq.m ; ./a.out
[ abc] [abcdefghij] [abc] [abcde]
[ abc] [abcdefghij] [abc] [abcde]
60 /tmp\>

Looks like just another nice new bug of the CoreFoundation thing...
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


References: 
 >Re: Bug in NSString stringWithFormat (or sprintf)? (From: Chris Boot <email@hidden>)

  • Prev by Date: Re: WTF? How can this work?
  • Next by Date: Re: PB launching wrong app after build
  • Previous by thread: Re: Bug in NSString stringWithFormat (or sprintf)?
  • Next by thread: RE: Bug in NSString stringWithFormat (or sprintf)?
  • Index(es):
    • Date
    • Thread