ex)
#include <stdio.h>
#include <string.h> struct man{
int age;
double height;
double weight;
char name[10];
char character[200];
};
void main(void){
struct man
tom; /*struct man형 변수 선언 */
struct man *ptr;
/*struct man형 포인터 선언 */
tom.age
= 20;
tom.height =
180.5;
strcpy(tom.name,
"Tom Crow valentaine");
ptr = &tom;
tom.weight
= 75.3;
printf("%f weight\n",
tom.weight);
ptr->weight
= 92.2;
printf("%f weight\n",
tom.weight);
printf("%f weight\n",
ptr->weight);
printf("%s is %f
weight.\n", ptr->name, ptr->weight);
}
|