From efc93bdc6a5852808f16cb65b91e8adb21201891 Mon Sep 17 00:00:00 2001 From: Felix Favre Date: Sat, 7 Jun 2014 18:21:13 +0200 Subject: [PATCH] Added little c-Script to ask for a Password --- challenge/challenge.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 challenge/challenge.c diff --git a/challenge/challenge.c b/challenge/challenge.c new file mode 100644 index 0000000..70c9443 --- /dev/null +++ b/challenge/challenge.c @@ -0,0 +1,30 @@ +#include +#include + +int main() { + int bytes_read; + size_t nbytes = 10; + char **my_string = malloc(sizeof(char**)); + char *password = "23door42\n"; + + puts("Please enter Password: "); + + bytes_read = getline(my_string, &nbytes, stdin); + + if(bytes_read == -1) { + puts("Error"); + return -1; + } else { + puts(password); + puts(*my_string); + if (strcmp(*my_string, password) == 0) { + puts("Success"); + return 0; + } else { + puts("How about no?!"); + return -1; + } + } + + return 0; +}