Store Struct data in a Vector

0

I'm trying to store data from a struct into a vector, except that I register 2 products to test, and when I call the show function in main it only shows the last product registered as if it had only read the last data inserted and replaced , but I declare to save in vector, and I can not know where I'm going wrong.

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



typedef struct
{   
char nome[30];
char codigo[8];
int status;
float preco;

}Produto;

 Produto vet_Repositorio[20];


int Inserir_produto(Produto *vet_Repositorio)
{
int i;
for(int i=1;i<2;i++){
printf("Digite a Nome :"); 
scanf("%s%*c",&vet_Repositorio[i].nome);
printf("Digite a codigo   :"); 
scanf("%s%*c",&vet_Repositorio[i].codigo);
printf("Digite o status   :"); 
scanf("%d", &vet_Repositorio[i].status);
printf("Digite o preco :"); 
scanf("%f", &vet_Repositorio[i].preco);
}



}

int mostrar_produto(Produto *vet_Repositorio)
{
int i;
for(int i=1;i<2;i++){
system("cls");
printf("Nome : %s\n", vet_Repositorio[i].nome);
printf("codigo   : %s\n", vet_Repositorio[i].codigo);
printf("status   : %d\n", vet_Repositorio[i].status);
printf("preco : %.3f\n", vet_Repositorio[i].preco);
}

}

    
asked by anonymous 18.10.2018 / 15:17

0 answers