• 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: Newbie Question about using selected file name with fopen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Newbie Question about using selected file name with fopen
      • From: Phil Faber <email@hidden>
References: 
 >Is there some magic in NSTextView binding? (From: Andrei Tchijov <email@hidden>)
 >Re: Is there some magic in NSTextView binding? (From: Ricky Sharp <email@hidden>)
 >Re: Is there some magic in NSTextView binding? (From: Andrei Tchijov <email@hidden>)
 >Newbie Question about using selected file name with fopen (From: Phil Faber <email@hidden>)

  • Prev by Date: Newbie Question about using selected file name with fopen
  • Next by Date: Re: Should I use Sync Services?
  • Previous by thread: Newbie Question about using selected file name with fopen
  • Next by thread: Re: Newbie Question about using selected file name with fopen
  • Index(es):
    • Date
    • Thread