Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define LENGTH 8
  4. int main () {
  5. char* username, *nlptr;
  6. int allow = 0;
  7.  
  8. username = malloc(LENGTH * sizeof(*username));
  9. if (!username)
  10. return EXIT_FAILURE;
  11. printf external link("Enter your username, please: ");
  12. fgets(username,LENGTH, stdin);
  13. // fgets stops after LENGTH-1 characters or at a newline character, which ever comes first.
  14. // but it considers \n a valid character, so you might want to remove it:
  15. nlptr = strchr(username, '\n');
  16. if (nlptr) *nlptr = '\0';
  17.  
  18. if (grantAccess(username)) {
  19. allow = 1;
  20. }
  21. if (allow != 0) {
  22. priviledgedAction();
  23. }
  24.  
  25. free(username);
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement