Advertisement
Guest User

Untitled

a guest
Nov 17th, 2010
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. char user_name[20] = "                   ";
  4. char password[20] = "                   ";
  5. char users[][2][20] =
  6. { { "root", "98765" },
  7.   { "moi", "allo" },
  8.   { "abc", "motdepasse" },
  9.   { "", "" }
  10. };
  11.  
  12. int check_name()
  13. {
  14.   int i;
  15.   printf("Name: "); gets(user_name);
  16.   printf("Pass: "); gets(password);
  17.  
  18.   for(i=0; users[i][0][0] != 0; i++)
  19.   {
  20.     if(strcmp(user_name, users[i][0]) == 0 &&
  21.        strcmp(password,  users[i][1]) == 0)
  22.        return 1;
  23.   }
  24.   return 0;
  25. }
  26.  
  27. void logon()
  28. {
  29.   printf("Welcome to system...\n");
  30.   exit(1);
  31. }
  32.  
  33. void reject()
  34. {
  35.   printf("Connection refused!\n"); 
  36.   exit(0);
  37. }
  38.  
  39. main()
  40. {
  41.   unsigned int i;
  42.   for(i=(unsigned)-3; i && !check_name(); i++);
  43.   if(i>=(unsigned)-3)
  44.     logon();
  45.   else
  46.     reject();
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement