Advertisement
Guest User

Untitled

a guest
Nov 11th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. int inserir_utilizador (int *user_id) {
  2. int ano, i, existe;
  3. existe = 0;
  4. char temp [100];
  5.  
  6. while (existe != 2){
  7. printf("Username:");
  8. fgets (temp, 100, stdin);
  9. temp [strlen(temp)-1] = '\0';
  10. for (i=0; i<n_utilizadores; i++){
  11. if (strcmp(temp, arrayUtilizadores[i].username)==0)
  12. existe = 1;
  13. }
  14. if (existe == 1){
  15. printf("O utilizador %s jรก existe. \n Por favor indique outro:\n", temp)
  16. ;
  17. existe =0;
  18. } else {
  19. *user_id = *user_id+1;
  20. printf ("Ano de Nascimento: " );
  21. scanf ("%d", &ano );
  22. limpar_linha();
  23.  
  24. arrayUtilizadores[n_utilizadores].user_id = *user_id;
  25. arrayUtilizadores[n_utilizadores].ano = ano;
  26. strcpy ( arrayUtilizadores[n_utilizadores].username, temp );
  27.  
  28. printf ("Password: ");
  29. fgets (temp, 100, stdin);
  30.  
  31. strcpy (arrayUtilizadores[n_utilizadores].password, temp );
  32. arrayUtilizadores[n_utilizadores].password [strlen(arrayUtilizadores[n_utilizadores].password) -1] = '\0';
  33. existe=2;
  34. n_utilizadores++;
  35. printf("O utilizador %s foi inserido com Sucesso.\n", arrayUtilizadores[n_utilizadores-1].username);
  36. }
  37. }
  38. existe=0;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement