PDA

View Full Version : [C] creazione di un file csv da una matrice di float


antimon
03-09-2007, 11:59
ciao...devo realizzare un file output csv creato da una matrice di float...quello che non riesco a fare č andare a capo della riga, ovvero quando apro il csv con excel tutti i valori sono uno di seguito all'altro sulla prima riga, la funzione č questa:

void creazione(char *fil)

{

FILE *fl;

int i,j;

fl=fopen(fil,"w+");

for (i=0;i<I;++i) {

for (j=0;j<J;j++) {

fprintf(fl, "%f",X[i][j]);

if(j<(J-1)) fprintf(fl,"%s",",");

if(j==(J-1)) ...... <<<<<<<<<<<<<<<

}

}

fclose(fl);

}

andbin
03-09-2007, 12:29
if(j==(J-1)) ...... <<<<<<<<<<<<<<<Devi mettere un fprintf (fl, "\n"); ma non nel loop pių interno, bensė dopo che il loop interno č terminato.

antimon
03-09-2007, 12:49
Devi mettere un fprintf (fl, "\n"); ma non nel loop pių interno, bensė dopo che il loop interno č terminato.

ti ringrazio :) ...cmq funziona anche messo nel loop interno sotto if...anche se effettivamente non ha senso, :p

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.