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 pointer to pointer to array of pointers to strings in C

1 Answer

0 votes
#include <stdio.h>

int main(int argc, char **argv) 
{ 
    char *scientists[] = {
                            "Albert Einstein",
                            "Isaac Newton",
                            "Marie Curie",
                            "Galileo Galilei",
                            "Charles Darwin"
                         };
    
    char **p = scientists;
                        
    puts(*p);
    puts(scientists[0]);
    
    putchar(**p);
    putchar('\n'); 
    putchar(scientists[0][0]);
    
    putchar('\n'); 
    
    puts(*(p + 1));
    puts(scientists[1]);
    
    putchar(**(p + 1));
    putchar('\n'); 
    putchar(scientists[1][0]);
    
    putchar('\n');
    
    putchar(*(*(p + 2)));
    putchar('\n');
    putchar(scientists[2][0]);
    
    putchar('\n');
    int i = 3, j = 6;
    putchar(*(*(p + i) + j));
    putchar('\n');
    putchar(scientists[i][j]);
        
    return 0;
}

/*
run:

Albert Einstein
Albert Einstein
A
A
Isaac Newton
Isaac Newton
I
I
M
M
o
o

*/

 



answered Jul 1, 2015 by avibootz

Related questions

...