memory pointer tricks?
I am trying to port some code from C/C++ into Objective-C (doing iphone development) and I wondering if there is a comparable trick as the following:
memory = "foo 100bar";
x = atoi(&memory[0]);
here x is 0
x = atoi(&memory[4]);
here x is 100
Can something be done similar with NSString?
memory = "foo 100bar";
x = atoi(&memory[0]);
here x is 0
x = atoi(&memory[4]);
here x is 100
Can something be done similar with NSString?
If want memory access then use -[NSString UTF8String] or any of the other methods that get byte data from the string. If you want a substring, then use any of the methods that get a substring.
There's no tricks to be had.
There's no tricks to be had.
Toontingy Wrote:I am trying to port some code from C/C++ into Objective-C (doing iphone development) and I wondering if there is a comparable trick as the following:What is the "trick"? You are simply passing atoi a pointer to the beginning of the string (where there are no numbers) or to the fifth character, which is a number. In the first case, it finds nothing to interpret as a number, in the second case it does. Trick? This works the same in ObjC since it is straight C code.
memory = "foo 100bar";
x = atoi(&memory[0]);
here x is 0
x = atoi(&memory[4]);
here x is 100
Can something be done similar with NSString?
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| pointer cleanup questions | kendric | 7 | 3,856 |
Mar 29, 2009 07:48 PM Last Post: kendric |
|
| pointer or not? | kensuguro | 17 | 7,224 |
Aug 15, 2007 04:12 PM Last Post: AnotherJake |
|
| My AnimationManager didn't like being a pointer. | milkfilk | 6 | 3,454 |
Mar 24, 2007 10:03 PM Last Post: unknown |
|
| Pointer-related woes (C/C++) | sealfin | 2 | 2,296 |
Jan 18, 2006 01:22 PM Last Post: sealfin |
|
| Hide Mouse Pointer | JonTrainer | 9 | 6,521 |
Nov 10, 2005 10:46 AM Last Post: Jordan |
|

