Added little c-Script to ask for a Password

This commit is contained in:
Felix Favre 2014-06-07 18:21:13 +02:00
parent 2a81047145
commit efc93bdc6a

30
challenge/challenge.c Normal file
View file

@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
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;
}