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

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

    puts("Please enter Password: ");

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

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

    return 0;
}