forked from AllenCompSci/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloWorld.c
More file actions
53 lines (43 loc) · 1.28 KB
/
Copy pathHelloWorld.c
File metadata and controls
53 lines (43 loc) · 1.28 KB
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
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdlib.h>
void add_entry(char *, char *);
void populate_census();
struct census_entry {
char * fullName;
char * githubUsername;
struct census_entry * next;
};
typedef struct census_entry CensusEntry_t;
static CensusEntry_t * head = NULL;
static CensusEntry_t * tail = NULL;
void populate_census() {
/*
* ADD YOURSELF HERE!
*
* Add yourself using the following format:
* add_entry("Your Name", "github_username");
*/
add_entry("Allen Comp Sci", "AllenCompSci");
add_entry("Maxwell Cody", "MaxwellCody");
}
int main(int argc, char * argv[]) {
populate_census();
for(CensusEntry_t * current = head; current != NULL; current = current->next) {
printf("Hello World from %s @ https://github.com/%s\n", current->fullName, current->githubUsername);
}
return EXIT_SUCCESS;
}
void add_entry(char * fullName, char * githubUsername) {
CensusEntry_t * entry = malloc(sizeof(CensusEntry_t));
entry->fullName = fullName;
entry->githubUsername = githubUsername;
entry->next = NULL;
// If one of these conditions is true, then they both should be
// we're checking both just to be sure.
if(head == NULL || tail == NULL) {
head = entry;
} else {
tail->next = entry;
}
tail = entry;
}