|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
[C] Lettura file
Ciao a tutti, ho un problema nel aprire un file. Non credo che ci siano errori nella funzione perche in un'altra funzione faccio la stessa cosa ma non mi da problemi. Il fatto è che quando apro il filename1 va avanti all'infinito. Il file è un .dat ma non vorrei che avendolo modificato con notepad di win abbiamo eliminato "qualcosa"?
La funzione è la seguente: Codice:
int legge()
{
FILE *file1, *file2;
int i=0;
int t;i;
double p[200];
if((file1=fopen(filename1,"r"))==NULL)
printf("Impossibile aprire il file");
else
{
i=0;
while(fscanf(file_weight1,"%LE",&p[i]))
{
printf(".");
i++;
if(i==500)
break;
}
}
}
__________________
"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: Jul 2006
Città: Tristram
Messaggi: 517
|
Prova a sostituire questa:
Codice:
while(fscanf(file_weight1,"%LE",&p[i])) Codice:
while(fscanf(file1,"%LE",&p[i]))
__________________
Il sole è giallo |
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
Quote:
Codice:
if((fweight1=fopen(filenamew1,"r"))==NULL)
printf("Impossibile aprire il file pesi_1.dat");
else
{
printf("Inizializzazione pesi!!\n");
i=0;
printf("Primo strato.\n");
while(fscanf(fweight1,"%LE",&p[i]))
i++;
}
__________________
"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...." |
|
|
|
|
|
|
#4 | |
|
Senior Member
Iscritto dal: Dec 2004
Messaggi: 783
|
Quote:
Codice:
if((fweight1=fopen(filenamew1,"r"))==NULL)
printf("\nImpossibile aprire il file");
else
{
printf("\nDati letti:\n");
i=0;
while(fscanf(fweight1,"%LE",&p[i])>0)
{
printf(".");
i++;
}
}
Grazie
__________________
"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: 19:22.



















