[bonus GRP] cara baca file .csv dengan bahasa C

20th November 2011 01:01 AM Linuxmania#1
urgent nih all

saya ditugaskan untuk buat coding pake bahasa C buat baca file .csv



saya udh coba buat kaya gini




Quote:





#include

#include

#include

#include



void main()

{

char temp[150][150];

char waktu[150][150];

float price[150];

char signal[150][5];

int volume[150];

int akhir;

int i,j=0;

char *p;



FILE *in;



in=fopen("Backtest_prototype.csv","r");





while(!feof(in))

{



fgets(temp[i],strlen(temp[i])+1,in);



p=strtok(temp[i],",");

strcpy(waktu[i],p);



p=strtok(NULL,",");

price[i]=atof(p);



p=strtok(NULL,",");

strcpy(signal[i],p);



p=strtok(NULL,",");

volume[i]=atoi(p);



i++;

}

fclose(in);





for(j=0;jhttp://www.4*shared.com/file/u2je0L5x/Backtest_prototype.html

saya cuma mau masukkin 1 1 filenya ke array, nanti saya proses

trus ntar hasilnya dimasukkin ke file CSV itu juga



dan sesuai judul buat masing2 yang bantuin saya kasih 1 GRP gratis buat penghargaan saya atas usahanya

makasih all:handshake:

</div>