View Single Post
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Arrays and Pointers

 
0
  #3
Dec 1st, 2008
Some additions:
1. To print pointer value use %p (not %d) format specifier. As usually, it's a senseless operation .
2. True type of a string literal is const char* - a constant pointer to the 1st element of a char array contained a string with terminated null character. You can't change string literal via pointer to it. Constructs like
  1. char* message1 = "C";
are valid (for backward compatibility with older C programs) but modern compilers place literals in read-only memory.
3. An array name is not converted to a pointer to the 1st element of an array (&array[0]) in sizeof array_name (operator sizeof argument position).
Last edited by ArkM; Dec 1st, 2008 at 6:04 am.
Reply With Quote