#include <stdio.h>
#include <stdlib.h>
#define MALLOC(p,s) \
if (!((p) = malloc(s))) { \
fprintf(stderr, "Insufficient memory"); \
exit(1); \
}
typedef struct Node {
int data;
struct listNode *link;
}listNode;
void printList(listNode *first) {
printf("The list contains: ");
for (; first; first = first->link)
printf("%4d", first->data);
printf("\n");
}
listNode create2() {
listNode *first, *second;
MALLOC(first, sizeof(*first));
MALLOC(second, sizeof(*second));
second->link = NULL;
scanf_s("%d", &first->data);
scanf_s("%d", &second->data);
first->link = second;
return *first;
}
void main() {
listNode a;
a=create2();
printList(&a);
}
- return *first; 를 써도 괜찮나요?
- typedef struct Node {
int data;
struct listNode *link;
}listNode;
여기서 Node와 listNode는 뭔차이죠?
댓글 입력