summaryrefslogtreecommitdiff
path: root/wk3/sect/candidate.c
blob: bb849dfd43a1bf4904302416f8bdc59f0c0a6ead (plain)
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
#include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
    string name;
    int votes;
} candidate;

candidate get_candidate(string prompt);

int main(void) {
    candidate president = get_candidate("Enter a candidate: ");
    printf("%s\n", president.name);
    printf("%i\n", president.votes);
}

candidate get_candidate(string prompt) {
    printf("%s\n", prompt);
    candidate c;
    c.name = get_string("Enter a name: ");
    c.votes = get_int("Enter a numbe of votes: ");
    return c;
}

/*
    struct makes a new
*/