1

I was asked this on an interview for an entry level position and was interested as to why you need two pointers. It was a phone interview and he had me write down

char **a[5]

and asked me what this was?

He told me that it was a pointer to an array of 5 characters in order to produce a string of 5 character. I am just trying to understand why its char **a[5] and not char *a[5].

2
  • 2
    This is an array of five pointers-to-pointer-to-char. There are no direct chars here.If he said this is a pointer to an array of five chars either you wrote it wrong, he said it wrong, or both. The proper decl for his description is char (*a)[5]; Side Note: Your char *a[5]; is an array of five pointers-to-char, so that doesn't match his description either. Commented Apr 9, 2013 at 19:30
  • Thats just the way I wrote it down on for the questions. Sorry that it was wrong, I didnt copy down what he said word for word but the important part would be that they use it to represent a string. What would be the advantage of having pointer to pointer to chars. Commented Apr 9, 2013 at 19:34

1 Answer 1

2

If you apply the right-left reading rule to that... a is an array of five pointers to a pointer to char.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.