Re: want backslash in NSString
Re: want backslash in NSString
- Subject: Re: want backslash in NSString
- From: Andreas Monitzer <email@hidden>
- Date: Mon, 31 Dec 2001 03:22:01 +0100
On Monday, December 31, 2001, at 03:02 , Christopher Anand wrote:
How do I get a backslash in an NSString?
I have tried the following:
string = [NSString stringWithCString: "\include" length:8]; // give
compiler warning
NSLog(string);
string = [NSString stringWithCString: "\\include" length:8];
NSLog(string);
string = [NSString stringWithCString: "\binclude" length:8];
NSLog(string);
cstring = "\\include";
printf("%s\n",cstring);
with the results:
2001-12-30 20:41:38.144 CircleView[403] include\\000
2001-12-30 20:41:38.145 CircleView[403] \\\\include
2001-12-30 20:41:38.145 CircleView[403] \\010include
\include
You forgot something:
int main() {
NSLog(@"%s","test\\test");
}
2001-12-31 03:18:50.995 test[18366] test\\\\test
NSLog is adding those additional backslashes, the NSString is fine.
btw I'd recommend @"\\include" instead of stringWithCString: using a
constant string (maybe you used it for testing only).
andy