Created
February 17, 2019 12:06
-
-
Save int0x33/bd9e38b230e7da56032d7d611c19bceb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define LENGTH 8 | |
int main () { | |
char* username, *nlptr; | |
int allow = 0; | |
username = malloc(LENGTH * sizeof(*username)); | |
if (!username) | |
return EXIT_FAILURE; | |
printf external link("Enter your username, please: "); | |
fgets(username,LENGTH, stdin); | |
// fgets stops after LENGTH-1 characters or at a newline character, which ever comes first. | |
// but it considers \n a valid character, so you might want to remove it: | |
nlptr = strchr(username, '\n'); | |
if (nlptr) *nlptr = '\0'; | |
if (grantAccess(username)) { | |
allow = 1; | |
} | |
if (allow != 0) { | |
priviledgedAction(); | |
} | |
free(username); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment