• 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: Incompatible pointer type
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incompatible pointer type


  • Subject: Re: Incompatible pointer type
  • From: "Jeffrey R. Kelley" <email@hidden>
  • Date: Fri, 15 Jan 2010 10:28:05 -0500

Gary,

It looks like you're passing an Objective-C string into a C function. Try this:

system([completeString cString]);

Jeffrey R. Kelley
email@hidden
Campus Computing Sites
Information and Technology Services
University of Michigan

On Jan 15, 2010, at 10:23 AM, Gary McGill wrote:


I am trying to pass a variable to system(). The final code would look like this:
system(“lp –d Internal_Modem –o phone=555-5555 ~/Desktop/fileToFax.pdf”)

If I simply put this line in my code, it works fine. The problem is I have to get the phone number from the database. When I build the string using AppendString I get “warning: passing argument 1 of ‘system’ from incompatible pointer type. Here is the code that builds the string:

      
NSString *numberToCall = [faxNumber stringValue];  // this gets the fax number from the database
    NSString *fileToPrint = @" ~/Desktop/fax.pdf";
    NSString *firstPartOfString = @"lp -d Internal_Modem -o phone=";
    NSString *addFaxNumber = [firstPartOfString stringByAppendingString:numberToCall];
    NSString *completeString = [addFaxNumber stringByAppendingString:fileToPrint];
    system(completeString); // THIS SHOULD WORK BUT DOES NOT
   NSLog(completeString);

In the run log the NSLog(completeString) looks perfect.
It also says “sh: line 1:  \240{\266x: command not found”

Why am I getting an incompatible pointer type?

Really all I need to do is pass the fax number variable to the system() call. If there is an easier way to do this I would greatly appreciate your comments.

Thanks,

Gary
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Incompatible pointer type (From: Gary McGill <email@hidden>)

  • Prev by Date: Incompatible pointer type
  • Next by Date: Re: Incompatible pointer type
  • Previous by thread: Incompatible pointer type
  • Next by thread: Re: Incompatible pointer type
  • Index(es):
    • Date
    • Thread