Ir ao conteúdo
  • Cadastre-se

valderivdkw

Membro Júnior
  • Posts

    1
  • Cadastrado em

  • Última visita

Reputação

0
  1. //alguem pode me ajudar a altera status de programa. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #define vdkw 100 int main(){ struct{ char desc[100]; char desc1[100]; float valor; float valor1; int cod,sta; int cod1,sta1,stac;} rept[vdkw]; FILE *arq; int op,cont,quant=0,rep=0,alt; float soma=0; do{ while(op !=6){ system("cls"); system(" COLOR F1"); printf(" ======== ESTOQUE ======== \n\n"); printf(" 1 Cadastro de Produtos:\n"); printf(" 2 Venda de Produto:\n"); printf(" 3 Lista de Produtos Vendidos:\n"); printf(" 4 Lista de Produtos de Estoque:\n"); printf(" 5 Saldo de Vendas:\n"); printf(" 6 Sair:\n\n"); printf(" Digite um Opcao: "); scanf("%d",&op); if(op==1){ system("cls"); printf("==== CADASTRO DE PRODUTOS ====\n"); printf("\n Digite Quantos Produtos Serao Cadastrados: "); scanf("%d",&quant); for(cont=0; cont<quant; cont++){ arq = fopen ("conta.txt", "r"); while((fscanf(arq," %d %s %f %d ",&rept[cont].cod1,&rept[cont].desc1,&rept[cont].valor1,&rept[cont].sta1))>0){ printf("\n %6d ",rept[cont].cod1); } printf("\n Digite o Codigo: "); scanf(" %d",&rept[cont].cod); if(rept[cont].cod==rept[cont].cod1){ printf("\n\n Codigo Igual! \n\n");} if(rept[cont].cod!=rept[cont].cod1){ printf(" Digite o Descricao: "); scanf("%s",&rept[cont].desc); printf(" Digite o Valor: "); scanf("%f",&rept[cont].valor); printf(" Digite o Status: "); scanf("%d",&rept[cont].sta); if(rept[cont].sta>1){ rept[cont].sta=1;} arq = fopen ("conta.txt", "a"); fprintf(arq,"\n %d %s %f %d ",rept[cont].cod,rept[cont].desc,rept[cont].valor,rept[cont].sta); fclose (arq); }} system("cls"); system("COLOR A0"); printf("\n\n Produto Cadastrado Com Sucesso! \n\n"); system("pause"); system("cls"); } if(op==2){ system("cls"); printf("==== VENDAS DE PRODUTOS ====\n"); printf("\n Codigo Descricao Valor Status "); printf("\n________________________________________\n"); arq = fopen ("conta.txt", "r+b"); while((fscanf(arq," %d %s %f %d ",&rept[cont].cod1,&rept[cont].desc1,&rept[cont].valor1,&rept[cont].sta1))>0){ printf("\n %6d %10s %7.2f %8d",rept[cont].cod1,rept[cont].desc1,rept[cont].valor1,rept[cont].sta1);} printf("\n Digite o Codigo Para Alterar: "); scanf("%d",&alt); if(rept[cont].sta>1){ rept[cont].sta=1;} switch(rept[cont].sta){ rept[cont].sta=1; break; } fclose (arq); fclose (arq); printf("\n_________________________________________\n"); printf("\n\n"); system("cls"); system("COLOR A0"); printf("\n\n Produto alterado com sucesso! \n\n"); system("pause"); system("cls"); } if(op==3){ system("cls"); printf("==== LISTA DE PRODUTOS VENDIDOS ====\n"); printf("\n Codigo Descricao Valor Status "); printf("\n________________________________________\n"); arq = fopen ("conta.txt", "r"); while((fscanf(arq," %d %s %f %d ",&rept[cont].cod1,&rept[cont].desc1,&rept[cont].valor1,&rept[cont].sta1))>0){ if(rept[cont].sta1==1){ printf("\n %6d %10s %7.2f %8d",rept[cont].cod1,rept[cont].desc1,rept[cont].valor1,rept[cont].sta1);}} fclose (arq); printf("\n_________________________________________\n"); printf("\n\n"); system("pause"); system("cls");} if(op==4){ system("cls"); printf("=== LISTA DE PRODUTOS NO ESTOQUE ===\n"); printf("\n Codigo Descricao Valor Status "); printf("\n________________________________________\n"); arq = fopen ("conta.txt", "r"); while((fscanf(arq," %d %s %f %d ",&rept[cont].cod1,&rept[cont].desc1,&rept[cont].valor1,&rept[cont].sta1))>0){ if(rept[cont].sta1==0){ printf("\n %6d %10s %7.2f %8d",rept[cont].cod1,rept[cont].desc1,rept[cont].valor1,rept[cont].sta1);}} fclose (arq); printf("\n_________________________________________\n"); printf("\n\n"); system("pause"); system("cls");} if(op==5){ system("cls"); printf("==== SALDO DE VENDAS ====\n"); arq = fopen ("conta.txt", "r"); while((fscanf(arq," %d %s %f %d ",&rept[cont].cod1,&rept[cont].desc1,&rept[cont].valor1,&rept[cont].sta1))>0){ if(rept[cont].sta1==1){ soma=soma+rept[cont].valor1;}} printf("\n R$%7.2f ",soma); fclose (arq); printf("\n\n"); system("pause"); soma=0; system("cls");} if(op==6){ op=6;} if((op>6)||(op==0)){ printf("\n Opcao Invalida!!!\n\n"); system("pause");} }} while(op !=6); return 0;}

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!