Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. int main (void)
  2. {
  3. int antalKonton;
  4. int i;
  5. int amount = 0;
  6. int namecheck = 0;
  7. char personFinder[30];
  8.  
  9. printf ("How many useraccounts do you want to enter? \n");
  10. scanf ("%d", &antalKonton);
  11.  
  12. struct account* arr= (struct account*) malloc (sizeof (struct account)*antalKonton);
  13.  
  14. if (arr == NULL)
  15. printf ("Could not allocate %d elements", antalKonton);
  16. else
  17. {
  18. for (i=0; i< antalKonton; i++)
  19. {
  20. arr[i] = konto();
  21. }
  22. printf ("Username: \t \t password: \n");
  23. for (i=0; i<antalKonton; i++)
  24.  
  25. {
  26.  
  27. printf ("%s \t \t %s \n", arr[i].username, arr[i].password);
  28. }
  29. do
  30. {
  31.  
  32.  
  33.  
  34. printf("enter the username of the person ur looking for:");
  35. scanf("%s", personFinder);
  36.  
  37. for (i = 0; i < amount; i++)
  38. {
  39.  
  40.  
  41. namecheck = (strcmp(arr[i].username, personFinder));
  42. if (namecheck == 0)
  43. {
  44. printf("the password associated with %s is: %s\n", personFinder, arr[i].password);
  45.  
  46. i = amount + i;
  47. }
  48.  
  49. }
  50.  
  51.  
  52.  
  53. if(namecheck >0||namecheck !=0)
  54. printf("no account with that name here\n");
  55.  
  56.  
  57.  
  58.  
  59. } while ((namecheck = (strcmp(personFinder, "none") != 0)));
  60.  
  61. }
  62.  
  63. free(arr);
  64.  
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement