Your struct has one member, you do not add any other member later, you can't do that outside the struct.
See my example:
// Example 1
// Referencing a structure member locally in "main()" with the "dot operator"
#include <stdio.h>
struct Test // unique definition of the struct
{
int x;
};
int main(void)
{
struct Test sTest; // we create an instance of the struct
sTest.x = 2; // we assign a value to the member of the struct
printf("x = %d\n",sTest.x);
return 0;
}
So, when you do:
MyStruct s;//method 1
MyStruct * ps;//method 2
you actually do this:
MyStruct s;
you say to create a struct of type MyStruct
, called s
. Memory will be allocated for it, but its members are not manually initialized, which you might want to remember!
Then this
MyStruct * ps;
creates a pointer to your struct, called ps
. That means, that ps
is ready to point to a struct of type MyStruct
. It is a POINTER to a struct, not a struct.
Source of my example is here.
As pointed by crhis, a book (see the relevant list of SO here) may be what you need, since there is much confusion in your post. An online tutorial would also be nice.
Also notice that C and C++ are two different programming languages.