0
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
typedef int TipoChave;
typedef int TipoDado;
typedef string TipoNome;
struct TipoRegistro {
TipoChave chave;
TipoDado dado;
TipoNome nome;
}TipoRegistro[1000];
void Imprimir(){
for(int i=0;i<1000;i++){
cout << TipoRegistro[i].chave << " / ";
cout << TipoRegistro[i].dado << endl;
cout << TipoRegistro[i].nome << endl;
}
}
void Preencher_Estrutura(string nomedoarq){
int chave,dado,i=0;
string nome;
ifstream arquivo;
arquivo.open(nomedoarq);
while(!arquivo.eof())
{
arquivo >> chave;
arquivo >> dado;
arquivo >> nome;
TipoRegistro[i].chave = chave;
TipoRegistro[i].dado = dado;
TipoRegistro[i].nome = nome;
i++;
}
arquivo.close();
}
int main(int argc, char** argv) {
string conteudo;
ifstream arquivo;
Preencher_Estrutura("GeraSeq1000.txt");
Imprimir();
return 0;
}
wouldn’t it be because you’re not seeing the previous lines being displayed? tries to change the
for
in FunctionImprimir
to count from 0 to 50 for example and valdar– Ricardo Pontual
I don’t know if I understand your program. If you want to read the file records why keep the 1'000 records in memory? If
Imprimir()
shows the records from what is in the vector in memory to what file? And how will you know what you saved if you didn’t read from the file and yes from the vector?– arfneto