Discussion: Superhero’s Secret Identity
Execute the code to understand the output and gain insights into array and pointer access.
We'll cover the following...
Run the code
Now, it's time to execute the code and observe the output.
Press + to interact
#include <stdio.h>#define SIZE 5int main(){int values[SIZE] = {2, 3, 5, 8, 13};int *v, x;/* initialize the pointer */v = values;for( x=0; x<SIZE; x++ ) {printf("%2d = %2d\n",values[x],*(v+x));}return(0);}
Understanding the output
The code uses both array and pointer notation to output the first five Fibonacci numbers:
2 = 23 = 35 = 58 = 813 = 13
Code output
Arrays and pointers
Arrays and pointers are similar but not exactly interchangeable. This relationship explains why many beginning C ...