Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,166 questions

40,722 answers

573 users

How to declare and use an array of pointers to integers in C

1 Answer

0 votes
#include <stdio.h>
  
#define LEN 5

int main ()
{
	int arr[] = {3, 5, 23, 871, 2};  
	int *array_of_pointers[LEN]; 
   
	for (int i = 0; i < LEN; i++) {
		array_of_pointers[i] = &arr[i];    
	}	
   
	for (int i = 0; i < LEN; i++) {
		printf("arr[%d] = %d\n", i, *array_of_pointers[i]);
	}
   
	return 0;
}





/*
run:

arr[0] = 3
arr[1] = 5
arr[2] = 23
arr[3] = 871
arr[4] = 2

*/

 





answered Jan 26, 2020 by avibootz
edited Jan 29, 2020 by avibootz

Related questions

...