myStruct
struct myStruct
あなたが使用する前にオブジェクトを作成する必要があるあなたのために定義したタイプです。
次のようにする必要があります。
typedef struct myStruct {
char *stringy;
} myStruct_t; //user defined data type
myStruct_t *obj;
// you need to allocate memory dynamically.
obj= (myStruct_t *) malloc(sizeof(myStruct_t));
利用方法:
scanf("%s",obj->stringy);
printf("%s",obj->stringy);
関数内:
my_free(char *str) //str is local string
{
obj->stringy=str;
}
このコードを試すこともできます:
typedef struct myStruct {
char stringy[20]; //char *stringy
} myStruct_t; //user defined data type
myStruct_t obj; //object creation
利用方法:
scanf("%s",obj.stringy);
printf("%s",obj.stringy);
関数内:
my_free(char *str) //str is local string
{
strcpy(obj.stringy,str);
}