trouble getting c-chars from NSString
trouble getting c-chars from NSString
- Subject: trouble getting c-chars from NSString
- From: Daniel Child <email@hidden>
- Date: Wed, 30 Mar 2005 16:49:46 -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