Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement