29 lines
645 B
C
29 lines
645 B
C
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
|
|
const char *password = "23door42\n";
|
|
|
|
int main(void) {
|
|
size_t input_size = 0;
|
|
char *input_line = NULL;
|
|
|
|
printf("Please enter Password: ");
|
|
|
|
// read in password from standard input, exit on error.
|
|
if (getline(&input_line, &input_size, stdin) == -1) {
|
|
perror("Error");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
// compare password, print info, exit appropriately
|
|
if (strcmp(input_line, password) == 0) {
|
|
puts("Success!");
|
|
exit(EXIT_SUCCESS);
|
|
} else {
|
|
puts("How about no?!");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|