bf5f98649d
- implicitly declaring library function is bad manner :)
33 lines
646 B
C
33 lines
646 B
C
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main() {
|
|
int bytes_read;
|
|
size_t nbytes = 0;
|
|
char *my_string = NULL;
|
|
char *password = "23door42\n";
|
|
|
|
puts("Please enter Password: ");
|
|
|
|
bytes_read = getline(&my_string, &nbytes, stdin);
|
|
|
|
if(bytes_read == -1) {
|
|
puts("Error");
|
|
free(my_string);
|
|
return -1;
|
|
} else {
|
|
if (strcmp(my_string, password) == 0) {
|
|
puts("Success");
|
|
free(my_string);
|
|
return 0;
|
|
} else {
|
|
puts("How about no?!");
|
|
free(my_string);
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|