Ir para conteúdo
Fórum Script Brasil
  • 0

Ajuda com estrutura


diego bocao

Pergunta

Estou com um problema enorme ..

quando vou armazenar minha estrutura em arquivo txt grava-se muita sujeira ... e n sei como tratar isso para que se armazene somente as variaveis pedidas

gotoxy(30,4);printf ("CADASTRO DE FUNCIONARIO");

                    if ((ARQUIVO=fopen("CAD_FUNC.txt","a")))
                        if (!ARQUIVO)
                           {
          
                            gotoxy(30,15);printf ("ERRO AO ABRIR ARQUIVO");

                           }//IF DE VERIFICAÇÃO DE ABERTURA
                            else
                                {
                                
                                 fseek(ARQUIVO,0,SEEK_END); // posiciona o cursor no fim do arquivo
                                 // ftell pega o tamanho do arquivo e divide pelo tamanho de uma estrutura cliente
                                 id=ftell(ARQUIVO)/sizeof(funcionario); // atribui a "id" o resultado do numero de registros presentes no arquivo
             
                    gotoxy(8,7);   
                    printf("%i",funcionario.COD_FUNCIONARIO=id+1); // contador

                    fflush(ARQUIVO);
                    gotoxy(8,10);
                    i=0;
                    a=0; 
                    while ( i != '')
                           {
                            ContNome[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.NOME[a]=ContNome[a];                       
                                 }
                           gets  (funcionario.NOME);
                  /**********************************************/ 
                    fflush(stdin);
                    gotoxy(46,10);
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContSobrenome[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.SOBRENOME[a]=ContSobrenome[a];                       
                                 }
                    gets   (funcionario.SOBRENOME);
                   /**********************************************/  
                                
                    fflush(stdin);
                    gotoxy(7,13);
                    
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContEndereco[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.ENDERECO[a]=ContEndereco[a];                       
                                 }
                    gets   (funcionario.ENDERECO);
                    /**********************************************/
                              
                    fflush(stdin);
                    gotoxy(62,13);
                    
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContNumero[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.NUMERO[a]=ContNumero[a];                       
                                 }
                    gets  (funcionario.NUMERO );
                    /**********************************************/

                    fflush(stdin);
                    gotoxy(10,16);
                    
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContCidade[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.CIDADE[a]=ContCidade[a];                       
                                 }
                    gets (funcionario.CIDADE);
                    /**********************************************/
                                         
                    fflush(stdin);
                    gotoxy(45,16);
                    
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContEstado[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.ESTADO[a]=ContEstado[a];                       
                                 }
                    gets (funcionario.ESTADO);
                    /**********************************************/
                              
                    fflush(stdin);
                    gotoxy(63,16);
                    
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContCep[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.CEP[a]=ContCep[a];                       
                                 }
                    gets (funcionario.CEP);
                    /**********************************************/
                   
                    fflush(stdin);
                    gotoxy(7,19);
                    
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContTel[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.TEL[a]=ContTel[a];                       
                                 }
                    gets (funcionario.TEL);
                    /**********************************************/
                     
                    fflush(stdin);
                    gotoxy(7,22);
                    
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContRG[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.RG[a]=ContRG[a];                       
                                 }
                    gets (funcionario.RG);
                    /**********************************************/
                    
                    fflush(stdin);
                    gotoxy(38,22); 
                    
                    i=0;
                    a=0;
                    while ( i != '')
                           {
                            ContCPF[a]=getch();
                            a++;
                           }
                            for (i=0;i<a;i++)
                                 {
                                  funcionario.CPF[a]=ContCPF[a];                       
                                 }
                    gets(funcionario.CPF);
                    /**********************************************/

                    
                    fflush(stdin);
                    
                    Confirmar(); 
                    scanf ("%c",&confirmar);
                    
                    if (toupper(confirmar) != 'N')
                        {
                         
                         fflush(ARQUIVO);
                         fwrite(&funcionario,sizeof(funcionario),1,ARQUIVO);

                         Efetuado(); 
                         
                         fclose (ARQUIVO); //fecha o arquivo de inserção
                         
                         }//IF DE GRAVAÇÃO 
                
                    else 
                        {
                     
                         fflush(stdin);
                         system("cls");
                         tela();
                         
                         gotoxy(25,11);
                         printf("CADASTRO EXCLUIDO");
                         getchar();
                         SetConsoleTextAttribute(hConsole, color=2);                    

                       }//EXCLUSÃO
                        
                   }//ESLE DE ABERTURA DO GRAVAÇÃO

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...