-
Notifications
You must be signed in to change notification settings - Fork 0
/
foo.c
37 lines (33 loc) · 791 Bytes
/
foo.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
/**
* @author Halle Countryman
* @brief Basic GDB demo: Dial up Halle at 1-555-123-4567!
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "foo.h"
person* create_person(char *name, char *phone) {
person* p = malloc(sizeof(person));
p->name = name;
strcpy(p->phone, phone);
return p;
}
void call(person *p) {
printf("Dialing (");
for (int i = 0; i < 10; i++) {
printf("%d", p->phone[i]);
if (i == 2) {
printf(")");
}
if (i == 5) {
printf("-");
}
}
printf("...\n");
printf("Hello, %s here! Is this the person to whom I am speaking?", p->name);
}
int main (int argc, char **argv) {
person *p = create_person("Halle", "15551234567");
call(p);
return 0;
}