Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/05/2007, 03:08
molakey
 
Fecha de Ingreso: abril-2007
Mensajes: 6
Antigüedad: 17 años, 8 meses
Puntos: 0
Re: Problema Con Ficheros Y Streams

Ya esta solucionado:

infile.open("data.txt"); // create input stream and connect "data" to it
in.open("data.txt");

if(!infile || !in)
{
cerr << "Unable to open file data.txt\n";
sc_stop();
}
else
{
cout << infile.tellg();
cout <<"\n";

// Read first line to know the length
infile.getline(line,N);
a1->columns=strlen(line);
cout << a1->columns;
cout << "\n";

// Count the number of lines
do
{
a1->rows++;
infile.getline(line,N);
}while(infile);

infile.close();
cout << a1->rows;
cout << "\n";

// Create the matrix
a1->constructor();
cout << "EXIT CONSTRUCTOR\n";

while((in)&&(i<a1->rows))
{
// Read next line
in.getline(line,N);
// Copy the read information into an array
a1->array[i]=line;

// Print the read information
cout << a1->array[i] << endl;
// Increase the index
i++;
}

cout << i;
cout << "\n";

in.close();
cout << "File closed\n";

// a1->destructor();

cout << "Memory deleted\n";
matrix_finished.write(1);
data.write(*a1);
}