Click here to Skip to main content
15,921,226 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalstrange questions about an array Pin
kcynic28-Mar-08 2:18
kcynic28-Mar-08 2:18 
GeneralRe: strange questions about an array Pin
Iain Clarke, Warrior Programmer28-Mar-08 2:34
Iain Clarke, Warrior Programmer28-Mar-08 2:34 
GeneralRe: strange questions about an array Pin
kcynic28-Mar-08 4:22
kcynic28-Mar-08 4:22 
GeneralRe: strange questions about an array Pin
CPallini28-Mar-08 2:56
mveCPallini28-Mar-08 2:56 
GeneralRe: strange questions about an array Pin
kcynic28-Mar-08 13:02
kcynic28-Mar-08 13:02 
GeneralRe: strange questions about an array Pin
CPallini29-Mar-08 23:13
mveCPallini29-Mar-08 23:13 
GeneralRe: strange questions about an array Pin
kcynic30-Mar-08 20:59
kcynic30-Mar-08 20:59 
AnswerRe: strange questions about an array Pin
Rajkumar R29-Mar-08 4:02
Rajkumar R29-Mar-08 4:02 
kcynic wrote:
int a[] = {1,2,3,4,5};
int* ptr = (int*)(&a+1);



kcynic wrote:
So,&a should be a point of a,its type should be int**.

no, &a is of type int (*)[5], not int **. Othercase is Don't think int ** and int [][], multi dimensional array are same the former stores pointer to some different location while later stores in values in contigious location.


kcynic wrote:
But,why ptr-1 point the last element of the array?

so, &a is of type int (*)[5], (not int **), so incrementing a pointer increments based on the type, so (&a + 1) actually points next to the enter size of array; since that is the type, int (*) [5].
so ptr - 1 points to last element.

i repeat int (*)[5] is not same as int **, you can ensure this by trying the following code,
int *ptr = (int *)(((int **)&a) + 1);
GeneralRe: strange questions about an array Pin
kcynic30-Mar-08 20:58
kcynic30-Mar-08 20:58 
GeneralMultilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
ganesa moorthy28-Mar-08 1:56
ganesa moorthy28-Mar-08 1:56 
QuestionRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
Rajesh R Subramanian28-Mar-08 2:01
professionalRajesh R Subramanian28-Mar-08 2:01 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
ganesa moorthy28-Mar-08 2:41
ganesa moorthy28-Mar-08 2:41 
QuestionRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
Rajesh R Subramanian28-Mar-08 2:56
professionalRajesh R Subramanian28-Mar-08 2:56 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
ganesa moorthy28-Mar-08 2:59
ganesa moorthy28-Mar-08 2:59 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
Rajesh R Subramanian28-Mar-08 3:10
professionalRajesh R Subramanian28-Mar-08 3:10 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
NormDroid28-Mar-08 2:59
professionalNormDroid28-Mar-08 2:59 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
Rajesh R Subramanian28-Mar-08 3:11
professionalRajesh R Subramanian28-Mar-08 3:11 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
ganesa moorthy28-Mar-08 2:41
ganesa moorthy28-Mar-08 2:41 
QuestionRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
Matthew Faithfull28-Mar-08 2:11
Matthew Faithfull28-Mar-08 2:11 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
ganesa moorthy28-Mar-08 2:46
ganesa moorthy28-Mar-08 2:46 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
Royaltvk28-Mar-08 4:33
Royaltvk28-Mar-08 4:33 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
Matthew Faithfull28-Mar-08 4:43
Matthew Faithfull28-Mar-08 4:43 
QuestionRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
ganesa moorthy28-Mar-08 4:52
ganesa moorthy28-Mar-08 4:52 
GeneralRe: Multilingual preparation - How to make Chinese Text or japanese text appear on menu items or button captions etc., Pin
Matthew Faithfull28-Mar-08 5:09
Matthew Faithfull28-Mar-08 5:09 
GeneralRe: Multilingual preparation - Small doubt may be silly sorry to trouble you [modified] Pin
ganesa moorthy29-Mar-08 1:53
ganesa moorthy29-Mar-08 1:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.