Saving the data in an array skips the next question

0

I have the following code:

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

struct cadastro_palestra
{
    char nome[50];
    char cpf[13];
    char email[70];
};

int main ()
{
    setlocale(LC_ALL, "Portuguese");

    int matriz[1][2], i, j; // linhas e colunas    

    struct cadastro_palestra cadastro;

    printf("\nFaça o cadastro para a palestra \n\n");

    for(i=1;i<=2;i++) // linhas
    {
        for(j=1;j<=3;j++) // colunas
        {
            printf("Digite o nome = ");
            gets(cadastro.nome);
            setbuf(stdin, NULL);
            printf("Digite o CPF (sem ponto ou hífen) = ");
            gets(cadastro.cpf);
            setbuf(stdin, NULL);
            printf("Digite o email = ");
            gets(cadastro.email);
            setbuf(stdin, NULL);

            printf("\n\n\n\n********* Ticket ********* \n\n\n\n");

            printf("Nome: %s.\n", cadastro.nome);
            printf("CPF: %s.\n", cadastro.cpf);
            printf("E-mail: %s.\n", cadastro.email);
            printf("Lugar garantido. O aluno ficará na fileira %d, cadeira %d.\n\n\n\n", i,j);
            scanf("%d", &matriz[i][j]);


            if (i == 2 && j == 3)
            {
                break;
            }
        }
    }

    printf("\n\n\n\n** Todos os lugares já foram preenchidos **");

}

Every time it runs the first time, everything works normally. However, the problem is when he must ask the person's name again, where that question is skipped, and the person's name is directly asked. Something like:

Faça o cadastro para a palestra 

Digite o nome = warning: this program uses gets(), which is unsafe.
Teste
Digite o CPF (sem ponto ou hífen) = 12345678900
Digite o email = [email protected]




********* Ticket ********* 



Nome: Teste.
CPF: 12345678900.
E-mail: [email protected].
Lugar garantido. O aluno ficará na fileira 1, cadeira 1.



Teste1
Digite o nome = Digite o CPF (sem ponto ou hífen) = 43214321432
Digite o email = teste1




********* Ticket ********* 



Nome: Teste1.
CPF: 43214321432.
E-mail: teste1.
Lugar garantido. O aluno ficará na fileira 1, cadeira 2.

Looking at the code, I did not find any errors, but since I'm a beginner in C, I may have let something happen. How do I get the name question not to be skipped?

    
asked by anonymous 08.11.2018 / 11:39

0 answers