Added little c-Script to ask for a Password
This commit is contained in:
parent
2a81047145
commit
efc93bdc6a
30
challenge/challenge.c
Normal file
30
challenge/challenge.c
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue