I understand the concept of pointers and arrays in C. My problem is the syntax of them. What is this:
char* var;
char var*;
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.
Your premise is wrong. The first is the pointer type and the second is well… nothing, it is not valid C++ (neither is C for that matter).
Static arrays are more like this:
Dynamic arrays are on the other hand usually done with vectors.
The confusion between arrays and pointers is a legacy from the C programming language, where
*(a+n)anda[n]mean the same thing, so we can use thea[n]even ifais a pointer, not an array. This is not very idiomatic in C++ though.