How do I declare a pointer to a character array in C?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I guess I’ll give this answer in parts:
Here’s a pointer to an array of
chars (I assumed a 10-element array):Let’s break it down from the basics:
is a pointer:
to an array:
of
chars:However, most of the time you don’t really want a pointer to an array, you want a pointer to the first element of an array. In that case:
Either
xoryare what you’re looking for, and are equivalent.Tip: Learn about
cdeclto make these problems easier on yourself.