Re: Escaping white space in an NSString
Re: Escaping white space in an NSString
- Subject: Re: Escaping white space in an NSString
- From: Seth Willits <email@hidden>
- Date: Thu, 21 May 2009 00:26:42 -0700
On May 20, 2009, at 11:26 PM, Bruce Johnson wrote:
The CLI is for a Cocoa App, but I need to call this in both Leopard
and iPhone
char mdfile[PATHSIZE];
strncpy(mdfile, <pathToFile>, MAXREAD);
FILE * stream = fopen(<pathToFile>, "rt");
Nothing here is command-line related at all.
the rest of the c-code iterates over a rather large text file getting
a line at a time, (fgets(inbuff,MAXREAD,stream)) make some
calculations and then go onto the next line.
So as you can see, a non-escaped, white space laden "pathToFile" will
return a bogus FILE *stream.
Mmmmm..... nooooo it won't. fopen, like pretty much every other
function/method, takes an unescaped string. Your problem lies
elsewhere, such as in not passing the right value to fopen. You
mentioned you're getting that path in an NSString. You should be
passing fopen the result of [string fileSystemRepresentation].
--
Seth Willits
_______________________________________________
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