Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. /*
  2. si metta a punto un'interfaccia web, che permetta ad un utente di
  3. inserire nome, cognome, username, password, e-mail e controllore
  4. che i dati inseriti siano validi; si ritengono valide username e
  5. password con minimo 8 caratteri e massimo 15 caratteri, mentre si
  6. ritiene valida una e-mail se al suo interno si riscontrano almeno
  7. una chiocciola ed un punto.
  8. Nel caso non sia soddisfatto qualche criterio dare un avviso alla
  9. pressione del tasto di registrazione dati.
  10. */
  11.  
  12. #include <iostream>
  13. #include <cstdlib>
  14. #include <string.h>
  15. #include <stdio.h>
  16.  
  17. using namespace std;
  18.  
  19. struct utente {
  20. char nome[20];
  21. char cognome[20];
  22. char username[15];
  23. char password[15];
  24. char email[35];
  25. };
  26.  
  27. utente scheda[10];
  28.  
  29. void inserisci_utente();
  30. void stampa_utente();
  31. void lista_utenti();
  32.  
  33.  
  34. int main () {
  35.  
  36. system("clear");
  37.  
  38. int menu;
  39. int exit;
  40.  
  41. do {
  42.  
  43. cout<<"########## menu admin ##########"<<endl;
  44. cout<<"1 - inserisci utente"<<endl;
  45. cout<<"2 - stampa dati singolo utente"<<endl;
  46. cout<<"3 - stampa lista utenti"<<endl;
  47. cout<<"4 - uscire dal programma"<<endl;
  48.  
  49. cout<<"-> "; cin>>menu;
  50.  
  51. switch(menu) {
  52. case 1:
  53. inserisci_utente();
  54. break;
  55. case 2:
  56. stampa_utente();
  57. break;
  58. case 3:
  59. lista_utenti();
  60. break;
  61. case 4:
  62. exit=4;
  63. break;
  64. }
  65. } while (exit!=4);
  66. }
  67.  
  68.  
  69.  
  70. //funzione inserisci utente
  71. void inserisci_utente() {
  72.  
  73. char op;
  74.  
  75. system("clear");
  76.  
  77. for(int y=0; y<10; y++) {
  78. cout<<"nome: ";
  79. fgets(scheda[y].nome, 20, stdin);
  80.  
  81. cout<<"cognome: ";
  82. fgets(scheda[y].cognome, 20, stdin);
  83.  
  84. cout<<"email: ";
  85. fgets(scheda[y].email, 35, stdin);
  86.  
  87. cout<<"username: ";
  88. fgets(scheda[y].username, 15, stdin);
  89.  
  90. cout<<"password: ";
  91. fgets(scheda[y].password, 15, stdin);
  92.  
  93. cout<<endl;
  94.  
  95. cout<<"inserire un altro utente (s/n): ";
  96. cin>>op;
  97.  
  98. if(op=='s' || op=='S') y=10;
  99. else y=y;
  100.  
  101. }
  102. }
  103.  
  104. void stampa_utente() {
  105. char username[15];
  106.  
  107. cout<<"inserisci il nick: ";
  108. cin.getline(username,sizeof(username));
  109.  
  110. for(int i=0; i<10; i++) {
  111. if(username==scheda[i].username) {
  112. cout<<"nome: "<<scheda[i].nome<<endl;
  113. cout<<"cognome: "<<scheda[i].cognome<<endl;
  114. cout<<"email: "<<scheda[i].email<<endl;
  115. cout<<"nick: "<<scheda[i].username<<endl;
  116. cout<<"password: "<<scheda[i].password<<endl;
  117. }
  118. }
  119. }
  120.  
  121.  
  122. void lista_utenti() {
  123. for(int i=0; i<10; i++) {
  124. cout<<"nome: "<<scheda[i].nome<<endl;
  125. cout<<"cognome: "<<scheda[i].cognome<<endl;
  126. cout<<"email: "<<scheda[i].email<<endl;
  127. cout<<"username: "<<scheda[i].username<<endl;
  128. cout<<"password: "<<scheda[i].password<<endl;
  129. cout<<endl;
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement