• 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: Passing a C String as an argument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing a C String as an argument


  • Subject: Re: Passing a C String as an argument
  • From: William Squires <email@hidden>
  • Date: Sun, 20 Apr 2008 21:06:46 -0500

I think he means, "how do you convert an NSString to a C-string?" But I could be wrong... :)

On Apr 20, 2008, at 12:33 PM, Clark Cox wrote:

On Sun, Apr 20, 2008 at 10:17 AM, Philip Bridson
<email@hidden> wrote:
Hi There,

Is there anyway to pass a C string from a Obj-C class to a C function as an
argument? I know that I can use pointers to the string but it gets a bit
messy as I am using pointers in the C function to manipulate the string. I
also could put it in C++ and it would work but I'm trying to avoid that. I
want a function that is portable and so it can't be written in Obj-C.


I'm sorry if this is really basic but I don't normally use C very much.

Unfortunately, a "C string" is, by definition, a pointer to a NUL terminated array of characters; they are *always* passed as a pointer. What are you doing to the string that requires complex pointer manipulation? Perhaps a better way can be found.


-- Clark S. Cox III email@hidden _______________________________________________

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:
40satx.rr.com


This email sent to email@hidden

_______________________________________________

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


References: 
 >Passing a C String as an argument (From: Philip Bridson <email@hidden>)
 >Re: Passing a C String as an argument (From: "Clark Cox" <email@hidden>)

  • Prev by Date: Re: After Unarchive Object Exists, After First GUI Action, gone...
  • Next by Date: Re: NSScrollView "autoscroll" while adding data?
  • Previous by thread: Re: Passing a C String as an argument
  • Next by thread: Re: Passing a C String as an argument
  • Index(es):
    • Date
    • Thread