helo,
my file r.csv is as follows
07 02 2011
09 05 2011
..
..
i don't know what is error. but the function is not being called..
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<conio.h>
int calday(float,float);
int main()
{// main start
FILE *in, *out;
char *rdf,*wdf;
char day[10],mon[10],year[10];
float Day,Mon,Year;
rdf="A:\\r.csv";
wdf="A:\\mizoout.csv";
in = fopen(rdf,"rb");
out = fopen(wdf,"w");
if(in == NULL)
{
printf("Cannot open input file.\n");
exit(1);
}
if(out == NULL)
{
printf("Cannot open output file.\n");
exit(1);
}
fprintf(out,"%s\n","day,month,year");
while(fscanf(in,"%s %s %s\n,",&day,&mon,&year)>0)
{ //while start
Day = atof(day);
Mon = atof(mon);
Year = atof(year);
calday(Day,Mon);
fprintf(out,"%f,%f,%f\n",Day,Mon,Year);
} // while end
printf("\nFile has successfully written");
fclose(in);
fclose(out);
getch();
return 0;
}//main end
int calday(float day,float month)
{
if(month == 2)
{
day = day + 31 ;
}
else if(month == 3)
{
day = day + 59;
}
else if(month == 4)
{
day = day + 90;
}
else if(month == 5)
{
day = day + 120;
}
else if(month == 6)
{
day = day + 151;
}
else if(month == 7)
{
day = day + 181;
}
else if(month == 8)
{
day = day + 212;
}
else if(month == 9)
{
day = day + 243;
}
else if(month == 10)
{
day = day + 273;
}
else if(month == 11)
{
day = day + 303;
}
else
{
day = day + 334;
}
return(day);
}