0
Hello, Good Afternoon. I am a computer student and I am having difficulties with a part of a code, which is for the delivery of a work of my course.
void criar_cliente()
{
/// Número do dia do aniversario, será armazenado como o id do usuário.
int id, j = 0;
printf ("\nInsira o dia do seu aniversario: ");
scanf ("%d", &id);
/// Se acaso houver um id já presente no vetor, o programa informa esse erro para o usuário.
if (id == clientes[j])
{
printf ("\n***Este Cliente já existe!***\n\n");
}
///Se o id não tiver presente no vetor, o programa vai criar um novo cliente.
else
{
j = j + 2;
clientes [j] = id;
printf ("\n\nCliente Criado com Sucesso!!!");
printf ("\n***O numero digitado será o seu identificador. Portanto não o esqueça!\n\n\n\n\n\n");
}
}
Client[ j ] is a vector that has 50 positions. This code is inside the "void creat_client()".
When I type a value, e.g.: 20, it stores in the first vector, when I type this value again, the program says that this number already exists. So far, the program meets the proposal I want. The problem is when I type a new value, e.g.: 3, instead of the program jumping to the next vector position, it updates the old value by putting 3 in its place.
Someone could help me with this code, I’m having it for a long time, and so far I haven’t found a solution. Thanks in advance.
You may not have posted the full code but in the post there are no definitions of the variables used. I believe that there is a lack of code in the research section and also no explanation of the reason for skipping positions in the vector.
– anonimo
The whole code is very big kkk, so I put only the part that is giving problems. I edited the code above by inserting the variables I forgot to put before. On jumping, it is in the sense that the vector only updates the values of position 0, rather than storing the next values at the following positions. EX: [ 0 ] = 20; [ 1 ] = 3, [ 2 ] = 8; What happens is that it only updates the values of vector 0, instead of putting the following values in the next vectors.
– Valter Vinicius