#이중연결

벨리엣벨리엣· 6년

질문C언어 strcpy질문드립니다

#include <stdio.h> #include <stdlib.h> typedef int element; typedef struct DListNode { // 이중연결 노드 타입 element data; struct DListNode* llink; struct DListNode* rlink; } DListNode; // 이중 연결 리스트를 초기화 void init(DListNode* phead) { phead->llink = phead; phead->rlink = phead; } // 이중 연결 리스트의 노드를 출력 void print_dlist(DListNode* phead) { DListNode* p; for (p = phead->rlink; p != phead; p = p->rlink) { printf("<-| |%d| |-> ", p->data); } printf("\n"); } // 새로운 데이터를 노드 before의 오른쪽에 삽입한다. void dinsert(DListNode *before, element data) { DListNode *newnode = (DListNode *)malloc(sizeof(DListNode)); strcpy(newnode->data, data); newnode->llink = before; newnode->rlink = before->rlink; before->rlink->llink = newnode; before->rlink = newnode; } // 노드 removed를 삭제한다. void ddelete(DListNode* head, DListNode* removed) { if (removed == head) return; removed->llink->rlink = removed->rlink; removed->rlink->llink = removed->llink; free(removed); } // 이중 연결 리스트 테스트 프로그램 int main(void) { DListNode* head = (DListNode *)malloc(sizeof(DListNode)); init(head); printf("추가 단계\n"); int i = 0; for (i = 0; i < 5; i++) { // 헤드 노드의 오른쪽에 삽입 dinsert(head, i); print_dlist(head); } printf("\n삭제 단계\n"); for (i = 0; i < 5; i++) { print_dlist(head); ddelete(head, head->rlink); } free(head); return 0; } 안녕하세요 다름이 아니라 과제중에 코드 오류때문에 다음단계로 넘어가질 못해서 질문드립니다. 위에가 풀코드고 실행시키면  31행에 incompatible implicit declaration of built-in function &#39;strcpy&#39; 라며 오류가 뜨는데 (해당줄은 // 새로운 데이터를 노드 before의 오른쪽에 삽입한다. 밑입니다.) strcpy(newnode->data, data); 이걸 바꿔야 되는건가요?ㅠ  
1.7K
2
0
kimho
kimho·2019-05-26
상단에 #include <string.h>를 추가해보시기 바랍니다. #include <string.h>