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.

40,026 questions

51,982 answers

573 users

How to use pointers to array in C

1 Answer

0 votes
#include <stdio.h>
 
int main(void)
{
    int array[3] = {0};
    int *p1 = &array[0], *p2 = &array[1];

    printf("p1 = %p\n", (void*) p1);
    printf("array = %p\n", (void*) array);
    printf("p2 = %p\n", (void*) p2);
    printf("&array[1] = %p\n", (void*) &array[1]);
    
    *p1 = 18;
    *p2 = 99;
    
    for (int i = 0; i < 3; i++)
        printf("%3d", array[i]);
     
    return 0;
}
   
    
/*
run:
    
p1 = 000000000022FE20
array = 000000000022FE20
p2 = 000000000022FE24
&array[1] = 000000000022FE24
 18 99  0
    
*/

 



answered Aug 12, 2017 by avibootz

Related questions

1 answer 137 views
1 answer 90 views
90 views asked Mar 20, 2022 by avibootz
2 answers 196 views
196 views asked Jan 29, 2020 by avibootz
1 answer 147 views
3 answers 239 views
...