Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int inserir_utilizador (int *user_id) {
- int ano, i, existe;
- existe = 0;
- char temp [100];
- while (existe != 2){
- printf("Username:");
- fgets (temp, 100, stdin);
- temp [strlen(temp)-1] = '\0';
- for (i=0; i<n_utilizadores; i++){
- if (strcmp(temp, arrayUtilizadores[i].username)==0)
- existe = 1;
- }
- if (existe == 1){
- printf("O utilizador %s jรก existe. \n Por favor indique outro:\n", temp)
- ;
- existe =0;
- } else {
- *user_id = *user_id+1;
- printf ("Ano de Nascimento: " );
- scanf ("%d", &ano );
- limpar_linha();
- arrayUtilizadores[n_utilizadores].user_id = *user_id;
- arrayUtilizadores[n_utilizadores].ano = ano;
- strcpy ( arrayUtilizadores[n_utilizadores].username, temp );
- printf ("Password: ");
- fgets (temp, 100, stdin);
- strcpy (arrayUtilizadores[n_utilizadores].password, temp );
- arrayUtilizadores[n_utilizadores].password [strlen(arrayUtilizadores[n_utilizadores].password) -1] = '\0';
- existe=2;
- n_utilizadores++;
- printf("O utilizador %s foi inserido com Sucesso.\n", arrayUtilizadores[n_utilizadores-1].username);
- }
- }
- existe=0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement