메뉴 건너뛰기

목록
profile
조회 수 14 댓글 3 예스잼 0 노잼 0

No Attached Image

이제야 알게됨 

C언어에서 화살표연산자는 구조체에서만 사용된다...

그러므로 이제는 연결리스트를 할 수 있게됨 ㅋㅋ

#include <stdio.h>

#include <stdlib.h>

struct NODE {

char* data;

struct NODE* link;

};

int main() {

 

struct NODE* week = (struct NODE*)calloc(1, sizeof(struct NODE));

struct NODE* node1 = (struct NODE*)calloc(1, sizeof(struct NODE));

struct NODE* node2 = (struct NODE*)calloc(1, sizeof(struct NODE));

struct NODE* node3 = (struct NODE*)calloc(1, sizeof(struct NODE));

 

week->link = node1;

node1->data = "MON";

node1->link = node2;

node2->data = "TUE";

node2->link = node3;

node3->data = "WED";

node3->link = NULL;

 

 

struct NODE *curr = week->link;

while (curr != NULL) {

printf("Today is %s\n", curr->data);

curr = curr->link;

}

free(week);

free(node1);

free(node2);

free(node3);

 

return 0; 

}

이거 이해한건 아님. 

  • profile
    그리드 2022.11.23 14:43
    struct NODE* node2 = (struct NODE*)calloc(1, sizeof(struct NODE));
    node2->data = 6;
    node2->link= node1->link;
    node1->link = node2;
  • profile
    그리드 2022.11.23 15:39(수정됨)
    순환 연결리스트는 쉽다.
    시작점을 head로 설정하게 하고
    head = node1;
    끝노드를 node->link = head 로 만들면 됨
  • profile
    그리드 2022.11.23 15:41
    이중 연결리스트는 복잡하기에 그려가면서 이해할 예정

공지 수용소닷컴 이용약관 asuka 2020.05.16
  1. No Image

    소프트웨어 공학 책

    Date2022.11.28 By그리드 Views8 Votes0
    Read More
  2. No Image

    일요일까지는 딥러닝 논문보다가

    Date2022.11.26 By그리드 Views20 Votes0
    Read More
  3. No Image

    확인용

    Date2022.11.23 By그리드 Views24 Votes0
    Read More
  4. No Image

    Date2022.11.23 By그리드 Views7 Votes0
    Read More
  5. No Image

    이더리움 일간 가격 데이터셋 만들기

    Date2022.11.23 By그리드 Views7 Votes0
    Read More
  6. No Image

    항공지도 이미지 처리방법의 예상순서

    Date2022.11.23 By그리드 Views13 Votes0
    Read More
  7. No Image

    UV-C LED

    Date2022.11.23 By그리드 Views7 Votes0
    Read More
  8. 이것저것 쓸만한 사이트 2

    Date2022.11.22 By저능아 Views32 Votes2
    Read More
  9. No Image

    도트연산자, 화살표연산자를

    Date2022.11.22 By그리드 Views14 Votes0
    Read More
  10. No Image

    그냥 막 적어봄

    Date2022.11.21 By그리드 Views10 Votes0
    Read More
  11. No Image

    아두이노 코스

    Date2022.11.21 By그리드 Views10 Votes0
    Read More
  12. No Image

    수요일엔 이거나 들어보는데수

    Date2022.11.21 By그리드 Views8 Votes0
    Read More
  13. No Image

    항공사진에서 적용할 효과

    Date2022.11.21 By그리드 Views7 Votes0
    Read More
  14. 긴급하게 패스트캠퍼스 CV활용과

    Date2022.11.19 By그리드 Views23 Votes0
    Read More
  15. No Image

    딱 한잔 마시고

    Date2022.11.19 By그리드 Views9 Votes0
    Read More
  16. No Image

    그... 그... 그...

    Date2022.11.18 By그리드 Views20 Votes0
    Read More
  17. No Image

    시밫 캡스톤 못하겟다

    Date2022.11.17 By그리드 Views22 Votes0
    Read More
  18. No Image

    HTTP 2.0과 3.0의 차이

    Date2022.11.16 By그리드 Views32 Votes0
    Read More
  19. No Image

    쿠르스칼 알고리즘

    Date2022.11.15 By그리드 Views18 Votes0
    Read More
  20. No Image

    7급 자료구조론

    Date2022.11.15 By그리드 Views11 Votes0
    Read More
목록
Board Pagination Prev 1 ... 6 7 8 9 10 11 12 13 14 15 ... 56 Next
/ 56