in the following function declaration
my_struct* create(char *name);
Is there any difference in the meaning of * in my_struct* and *name?
I understand that char *name means that we will pass a char pointer to the function my_struct called name. I also get that the function will return a pointer to (memory address of) something. What I don't understand is why my_struct* and not *my_struct?
In this declaration
the name of the function is
create. The function has one parameter of the typechar *, And the function has the return typemy_struct *. That is it returns a pointer to an object of the typemy_struct.my_structis a type specifier. Somy_struct *is a pointer type.nameis identifier that denotes the name of a parameter. The type of the parameter (identifier)nameischar *.Pay attention to that these declarations of the parameter are the same
that is the type of the parameter is
char *and the name of the parameter isname.In a function declaration that is not at the same time its definition names of parameters may be omitted.
So the above function declaration can be also written like