Jump to content

Matheus Rocha

Members
  • Content count

    1
  • Joined

  • Last visited

Community Reputation

0 Comum

About Matheus Rocha

  1. Matheus Rocha

    Como tratar os dados de um arquivo .txt

    Galera bom dia ! Me chamo matheus e estou com muita dificuldade na solução de um algorítimo que foi imposto e designado para eu solucionar. O que acontece, Eu tenho um arquivo .txt onde ele tem diversas informações. Ex Real: 1201604/08/2017 11:37:31Todas MTTT T06/07/201703/08/2017000000000000000000000000000000 2ANGRA DOS REIS 0000000014 385178911J39164256000170VIA SAT COMERCIAL ELETRONICA LTDA ME NNS07/07/2017 08:28:33 DN NNNNNNN000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000S 5SSSSN000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000 6 JOSÉ JORGE MARQUES 24 33652762SIDNEI COSTA VIEIRA 24 33652762 383067241J29355260000242TRIUNFO LOGISTICA LTDA NNS17/07/2017 16:20:05 DN NNNNNNN000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000S 5NNSNN000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000 6 wilson@wleme.com JORGE RODRIGUES DA SILVA 21 21788800WILSON ROBERTO LEME 21 21788800 378884096J11112293000204VALE DO CAFE AUTO POSTO LTDA NRS17/07/2017 16:22:44 DN SNSNNNN000000558482002000000000000000000000000000000000000914863662000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000558482002000000914863662000000000000000000000000000000000000000000000000000000000000000000000711192000000000000000000000000000000000000000000000000000355670468 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000355670468S 4N00037000000000711192 5NNNNN000000087369776000000000000000000000000000000000000000000000N000000083505478000000000000000000000000000000000000000000000N000000074110649000000000000000000000000000000000000000000000N000000075302716000000000000000000000000000000000000000000000N000000068143708000000000000000000000000000000000000000000000N000000067633557000000000000000000000000000000000000000000000N000000074329043000000000000000000000000000000000000000000000N000000077872727000000000000000000000000000000000000000000000N000000075293488000000000000000000000000000000000000000000000N000000078980667000000000000000000000000000000000000000000000N000000063227581000000000000000000000000000000000000000000000N000000088383080000000000000000000000000000000000000000000000 6 HAROLDO DA SILVA MANCEBO 24 24534614DANIEL MARIA DINIZ 24 24533886 385454455J00468285000190TRANZIRAN TRANSPORTES LTDA NRS19/07/2017 11:01:58 DN SNNSNNN000029414831790000000701696111000000000000000000044743461671000001941418951000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030116527901000046684880622000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001040394000000001040394 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001040394N 4N00026000000001040394 379050008J11921635000148GB segurança ELETRONICA DE ANGRA LTDA NNS20/07/2017 16:17:50 DN NNNNNNN000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000S 5SSSSN000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000N000000000000000000000000000000000000000000000000000000000000 o mesmo quer que eu faça um programa para ler esse conteúdo do arquivo txt a cima linha por linha e formate o mesmo gravando em um outro txt mas o formato é linha continua até o 2 que é o primeiro caractere Resumindo é um programa para eu pegar um arquivo já pronto e transformar ele como demonstrado a cima salvando em outro txt. Só que estou encontrando muitas dificuldades pra isso, eu consigo ler o arquivo e criar o local de salvamento com os dados, só que na formatação não consigo jogar a lógica na qual consiste em: O programa tem que na primeira linha identificar que é 2 sempre que tiver 2 no inicio da linha ele vai dar uma quebra de linha e continuar escrevendo até encontrar novamente o 2 no inicio da linha. OBS: o meu programa ta 100% funcional até então, mas eu não consigo jogar uma logica para o citado a cima. ele ler e grava em outro arquivo como já está em linha continua. só tenho que criar uma logica para poder fazer ele ter quebra de linha sempre que o caractere o primeiro caractere da linha for 2. MEU CÓDIGO: #include <iostream> #include <fstream> #include <locale> using namespace std; int main() { setlocale(LC_ALL, "Portuguese"); ifstream arquivo; ofstream arquivox; string linha; arquivo.open("Declan.txt"); // abre arquivo p leitura arquivox.open("Teste.txt"); // abre arquivo p escrita if (arquivo.is_open() && arquivox.is_open()) { while (getline(arquivo, linha)) { cout << linha; // lê o arquivo linha a linha arquivox << linha; // escreve no arquivo system("pause"); } arquivo.close(); arquivox.close(); } else { cout << "Não foi possivel abrir o arquivo" << endl; } return 0; } return 0; }
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.