Isaac87 2014. 6. 21. 15:59

 

#include <stdio.h>
struct point
{
    int x;
    int y;
};

int main(void)
{
    struct point p1={10, 20};
    struct point p2={0, 0};
   
    p2=p1;            // 구조체 변수 p2에 p1을 복사
     
    printf("%d %d \n", p1.x, p1.y);
    printf("%d %d \n", p2.x, p2.y);
     
    return 0;
}
 

 

 

링크드 리스트

#include<stdio.h>

struct student {
    char name[20];   
    struct student* link; 
};
int main(void)
{
 struct student s1 = {"A", NULL};
 struct student s2 = {"B", NULL};
 struct student s3 = {"C", NULL};
 struct student *p;
 
 s1.link = &s2;
 s2.link = &s3;

 
 p = &s1;
 while(p != NULL) {
  printf("%s\n", p->name);
  p = p->link;
 }
    return 0;