|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
[C] Leggere matrice numeri da file .dat
Buon giorno a tutti, questa è una domanda passata e ripassata ma tuttora non ho trovato una soluzione ottimale al mio problema. In sintesi devo leggere una matrice di dati da un file. Al momento faccio nel seguente modo:
Codice:
if((fdati=fopen(stringa,"r"))==NULL)
printf("Impossibile aprire il file");
else
{
printf("Lettura dati in corso\n");
while(fscanf(fdati,"%le %le %le %le %le %le %le",&data->matrice[t][6],&data->matrice[t][0],&data->matrice[t][1],&data->matrice[t][2],&data->matrice[t][3],&data->matrice[t][4],&data->matrice[t][5])>0)
{
if(t>punti-1)
{
printf("\n");
break;
}
//printf(".");
t++;
}
}
fclose(fdati);
Grazie a tutti.
__________________
"May the wind always be at your back and the sun upon your face. And may the wings of destiny carry you aloft to dance with the stars...." |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: May 2005
Città: Bari
Messaggi: 349
|
non è più semplice dedicare 8bytes alla fine del file per due interi che memorizzino le dimensioni?
"matrice[t][6]" se posso permettermi, una scrittura del genere non la utilizzerei mai... Vito
__________________
Si può vincere una guerra in due...o forse anche da solo. Si può estrarre il cuore anche al più nero assassino, ma è più difficile cambiare un'idea! |
|
|
|
|
|
#3 | ||
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
Quote:
Quote:
PS Al momento ho risolto cosi la parametrizzazione delle colonne: leggo tutti i dati in un vettore temporaneo. Successivamente creo la matrice cosi: Codice:
data->matrice[t][j]=tempread[i+t*colonne];
__________________
"May the wind always be at your back and the sun upon your face. And may the wings of destiny carry you aloft to dance with the stars...." |
||
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 11:52.




















