Re: Newbie Question about using selected file name with fopen
Re: Newbie Question about using selected file name with fopen
- Subject: Re: Newbie Question about using selected file name with fopen
- From: "Tim Buchheim" <email@hidden>
- Date: Fri, 7 Apr 2006 16:06:19 -0700
> NSString *myFile = [panel filename];
myfiles is an NSString*
> // Set file pointer to selected file (this line fails)
> fp1=fopen(myFile,"rb");
fopen() is expecting a char* as its first argument
> However, the <fp1=fopen(myFile,"rb");> fails to set the file pointer
> to that file, giving me a <warning: passing argument 1 of 'fopen'
> from incompatible pointer type> error.
That's because NSString* and char* are incompatible pointer types.
I'd suggest switching away from fopen() and using Cocoa's file
manipulation facilities instead. If you want to use fopen(), then I
believe you can use something like this:
fopen([myfile fileSystemRepresentation], "rb");
See the NSString documentation for more information about
fileSystemRepresentation
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html#//apple_ref/occ/instm/NSString/fileSystemRepresentation
--
Tim Buchheim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden