-1

Declared char array (read-only): const char alpha [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

Given a char pointer called ptr and the alpha array declared above, how would I make ptr point to the letter 'D'?

I think its ---> char *alpha[3]; because its pointing to the third index of the array.

ee ee
  • 3
  • 3
  • 1
    Is this homework? – n. m. could be an AI Mar 06 '17 at 04:14
  • Yes, and I'm very frustrated. – ee ee Mar 06 '17 at 04:26
  • If this is a homework question, please have a read of the following: http://meta.stackoverflow.com/a/334823/2641278. Homework questions are OK on this site but you need to follow the guidelines and [edit](http://stackoverflow.com/posts/42617428/edit) your question accordingly. – Adrian Sanguineti Mar 06 '17 at 04:27
  • The key thing you're missing at the moment is: "Make a good faith attempt to solve the problem yourself first." You've provided zero evidence that you have done so. – Adrian Sanguineti Mar 06 '17 at 04:28
  • I keep reverting back to... char *alpha[3]; – ee ee Mar 06 '17 at 04:29
  • If you really stuck in getting started, then Stack Overflow is probably NOT the best place to get help for you right now. You should instead have a chat with you're instructor/teacher. – Adrian Sanguineti Mar 06 '17 at 04:31
  • Thank you for your time. – ee ee Mar 06 '17 at 04:33
  • "I keep reverting back to... char *alpha[3];", OK so that information should be in your question, not the comments, so [edit](http://stackoverflow.com/posts/42617428/edit) your question and add that information in and explain yourself as to why you think that this is the answer. – Adrian Sanguineti Mar 06 '17 at 04:34

1 Answers1

0

Here you go

D is 3 index away from starting address of alpha that is A.

So your pointer should be initialized like this

char *ptr = alpha + 3;
not_python
  • 904
  • 6
  • 13