int a[10][20][30][40];
int *p

How to access an element of a using p?

.... PLs provide the actual code for the solution

Recommended Answers

All 2 Replies

To access element at a[5][4][9][20], use

printf("%d", *(*(*(*(a+5)+4)+9)+20));
int main()
{
  int a[10][20][30][40];
  a[0][0][0][0] = 314159;
  a[0][0][0][1] = 1414;

  int *p = &a[0][0][0][0];
  printf("%i \n", *p);
  
  p++;
  printf("%i \n", *p);
 
  return 0;
  
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.