Amazon.com Widgets about array and pointer
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 24, 2014, 05:17:15 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 13 - Underlying C Language Features
| | | |-+ about array and pointer
Pages: [1] Go Down
Print
Author Topic: about array and pointer (Read 614 times)
bamboo
Newbie
*
Posts: 14






on: April 18, 2011, 03:22:24 PM

I was reading pointers on chapter13 today, and had a question.
since a array name without a subscript is a pointer to the beginning of the array,
why can't we use increment on the array name like ++array,
and when you assign it to a pointer variable, you can do that with pointer?

for example, we have a character array
char array[] = {'a','b','c','\0'}
and you cannot do this:
NSLog(@"%c", *(++array));
although this works fine:
NSLog(@"%c", *(array+1));

then you assign it to a pointer:
char *ptr = array;
then it works:
NSLog(@"%c", *(++ptr));

anyone knows why???
Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.