30 likes | 230 Views
Pointers and Arrays. int table [8]; int *ptr ; ptr = table ; table [ 4 ] = 94; *( ptr + 4 ) = 94; How about ptr = & table[0] ?? vs. ptr=table ;??. 94. table. ptr. ( ptr + 4 ). Pointer Arithmetic. 0x5010 | a 0x5011 | b 0x5012 | F 0x5013 | H 0x5014 | X
E N D
Pointers and Arrays int table [8]; int *ptr ; ptr = table ; table [ 4 ] = 94; *( ptr + 4 ) = 94; How about ptr = & table[0]?? vs. ptr=table;?? 94 table ptr ( ptr + 4 )
Pointer Arithmetic 0x5010 | a 0x5011 | b 0x5012 | F 0x5013 | H 0x5014 | X 0x5015 | Y Given the following pointer and array. char array[6]; char *ptr 1) Initialize the pointer ptr and make it point to the first element of the array? ptr = array; or ptr = & array[0]; 2) What are the values of the following? &array[0]? _________________ (ptr+ 3)? ___________________ array[0]?___________________ *(ptr + 3)?___________________ *ptr? ______________________ &array[3]?___________________ (*ptr)+2?___________________ array[3]?___________________ Array[6]