Código:
#include<iostream>
#include<string>
#include<fstream>
#include <sstream>
using namespace std; //evita que escriba el nombre del paquete std para cada funcion ej: std::cout...
int main()
{
struct transaccion
{
string campo1;
string campo2;
string campo3;
string campo4;
};
struct transaccion trx;
ifstream input;
input.open("Transacciones.txt",ios::in);
char buffer[250];
while(!input.eof())
{
char *auxSplit;
input.getline(buffer,250);
auxSplit = strtok(buffer,";"); /* Separador ";" */
trx.campo1 = auxSplit;
cout << trx.campo1 << "\n";
auxSplit = strtok (NULL, ";");
trx.campo2 = auxSplit;
cout << trx.campo2 << "\n";
auxSplit = strtok (NULL, ";");
trx.campo3 = auxSplit;
cout << trx.campo3 << "\n";
auxSplit = strtok (NULL, ";");
trx.campo4 = auxSplit;
cout << trx.campo4 << "\n";
delete(auxSplit);
}
input.close();
return 0;
}