difference between char

What is the difference between char[], char * and char x[] ?

elandh: What is the difference between char[], char * and char x[] ?

Two are valid. One is not.

char x[] declares an array of chars of unknown size. The rest of the statement will define the size and the initial values.

char *p; defines a pointer, but does not make it point to anything. By itself, it is useless. If it is made to point to something, it can be quite useful.

PaulS:
Two are valid. One is not.

char x declares an array of chars of unknown size. The rest of the statement will define the size and the initial values.

char *p; defines a pointer, but does not make it point to anything. By itself, it is useless. If it is made to point to something, it can be quite useful.

hi PaulS
in arduino we can do char x but we should define the size first, and we can’t do char x it will make error like “expected unqualified-id before ‘[’ token”

char[] x is C# (and maybe other languages).

PaulS: char x[] declares an array of chars of unknown size. The rest of the statement will define the size and the initial values.

char *p; defines a pointer, but does not make it point to anything. By itself, it is useless. If it is made to point to something, it can be quite useful.

If char x[]; is a declaration of an array, char *p; should also be the declaration of a pointer variable and NOT a definition. Definition embeds declaration and not the other way?

GolamMostafa: If char x[]; is a declaration of an array, char *p; should also be the declaration of a pointer variable and NOT a definition. Definition embeds declaration and not the other way?

How does that help the OP?

...R