mardi 7 avril 2015

Array manipulation (accessing specific bytes)

Vote count:


I saw a video lecture about arrays and the lecturer said the output result of

int arr[5];
((short *)arr)[6]=2;
cout << arr[3] << endl;

would be 512+128. I implement the code on my text editor, but after compile and run it the output is 2. My doubt is if my code is not correct or if the instructor is somehow wrong (or if I am misunderstanding some aspect) . Thanks in advance.

My code:

#include <stdio.h>
int main(){
int array[5];
printf("%d\n", array[3]);
return 0;

asked 1 min ago

Array manipulation (accessing specific bytes)

Aucun commentaire:

Enregistrer un commentaire