Hi all,

I am trying to point a pointer to another pointer and just failed to get resultm here's my failed code,

char *point[] {
"This is One"
"This is Two"
"This is Three"
};

char *ptr;

ptr = point[2];
printf("%s\n", ptr);

I am getting single space printed out instead of "This is Three"
Am I doing wrong, how should I point ptr to point[3]????

Any Help will be appreciated

Rgds,
Will

Recommended Answers

All 2 Replies

I got it worked i mised ',' in *point declaration

char *point[] {
"This is One",
"This is Two",
"This is Three",
};

But Now compiler is making warning but working absolutly correct
Warning is "warning: assignment discards qualifiers from pointer target type"

Am I still wrong?? or warning is just warning not error

Rgds
Will

you also need to add the = symbol

char *point[]  ={
"This is One",
"This is Two",
"This is Three",
};
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.