Re: Bug in NSString stringWithFormat (or sprintf)?
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