I have been struggling with this for two days now, with no luck. I have a C char array char myArray[] = "Hello World";
I also have a pointer to pointer to char char **ptr;
So I want to somehow store myArray to ptr or somehow convert myArrayinto pointer to pointer to char .
Any suggestions of how I can achieve this.

Recommended Answers

All 4 Replies

I would try ptr = &myArray;

Thanks Gribouillis, I tried that but the below program fails at line 10:

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
    char ar[200] = "Hello World";
    strcat(ar, " !");
    printf("%s\n", ar);

    char **p = &ar;
    printf("%s\n", *p[0]);

    return 0;
}

This one works

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
    char ar[200] = "Hello World";
    strcat(ar, " !");
    printf("%s\n", ar);

    char* q = ar;
    char **p = &q;
    printf("%s\n", *p);

    return 0;
}

note that I'm only an occasional C programmer.

first of all learn many site for c .

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.