• 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
trouble getting c-chars from NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trouble getting c-chars from NSString


  • Subject: trouble getting c-chars from NSString
  • From: Daniel Child <email@hidden>
  • Date: Wed, 30 Mar 2005 16:48:26 -1000

Hi All,

Sorry, I am a newbie and I only did a tiny bit of C, so this question is pretty basic. I am trying to convert an NSString to a C-String so that I can remove certain characters. Somehow I don't seem to be able to get the cString returned from the [NSString cString] method to be assigned to a character array.

Here's what I have at this point.

NSString *original = @<some string of characters that contains digits> e.g. asd5sd
char *origChars = [original cString]; // my c-string

*charPtr;
char charArray[];
char newWord[]; // a word without numbers
int numCharsInNewWord

If I try to assign origChars to either *charPtr or charArray, I get an error. What I'm hoping to do is to get a word that is devoid of numbers.

numCharsInNewWord = 0;
while (charPtr != '\0') {
if (charPtr >= '\0' && charPtr <= '\9')
; // don't copy digits
else
newWord[numCharsInNewWord++];
charPtr++;
}

Thanks in advance!

Daniel


 _______________________________________________
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: trouble getting c-chars from NSString
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: trouble getting c-chars from NSString
      • From: Justin Spahr-Summers <email@hidden>
  • Prev by Date: NSTableView and row selection
  • Next by Date: trouble getting c-chars from NSString
  • Previous by thread: Re: NSTableView and row selection
  • Next by thread: Re: trouble getting c-chars from NSString
  • Index(es):
    • Date
    • Thread