challenge.c 626 Bytes
Newer Older
1
2
3
#include <stdio.h>
#include <stdlib.h>

gnomus's avatar
gnomus committed
4
int main() {
5
    int bytes_read;
anthraxx's avatar
anthraxx committed
6
7
    size_t nbytes = 0;
    char *my_string = NULL;
8
9
10
11
    char *password = "23door42\n";

    puts("Please enter Password: ");

anthraxx's avatar
anthraxx committed
12
    bytes_read = getline(&my_string, &nbytes, stdin);
13
14
15

    if(bytes_read == -1) {
        puts("Error");
anthraxx's avatar
anthraxx committed
16
        free(my_string);
17
18
        return -1;
    } else {
anthraxx's avatar
anthraxx committed
19
        if (strcmp(my_string, password) == 0) {
20
            puts("Success");
anthraxx's avatar
anthraxx committed
21
            free(my_string);
22
23
24
            return 0;
        } else {
            puts("How about no?!");
anthraxx's avatar
anthraxx committed
25
            free(my_string);
26
27
28
29
30
31
            return -1;
        }
    }

    return 0;
}