-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
44 lines (33 loc) · 947 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "list.h"
struct Person
{
char name[30];
unsigned int weight;
unsigned char gender;
struct list_head list;
};
int main()
{
struct Person personList;
INIT_LIST_HEAD(&personList.list);
struct Person* aNewPersonPointer;
aNewPersonPointer = malloc(sizeof(*aNewPersonPointer));
strcpy(aNewPersonPointer->name, "roman10");
aNewPersonPointer->weight = 130;
aNewPersonPointer->gender = 1;
INIT_LIST_HEAD(&aNewPersonPointer->list);
list_add(&aNewPersonPointer->list, &personList.list);
struct Person* aNewPersonPointer2;
aNewPersonPointer2 = malloc(sizeof(*aNewPersonPointer));
strcpy(aNewPersonPointer2->name, "roman20");
aNewPersonPointer2->weight = 130;
aNewPersonPointer2->gender = 1;
INIT_LIST_HEAD(&aNewPersonPointer2->list);
list_add(&aNewPersonPointer->list, &personList.list);
printf("%s\n",personList.list->name);
return 0;
}