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

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,726 questions

51,615 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

1 answer 193 views
1 answer 150 views
1 answer 173 views
1 answer 139 views
...