I want to write that "mjd1" value to a text file. I tried it using fprinf() function. but it dint work.
Code:
#include<iostream.h> #include<conio.h> #include<dos.h> #include<stdio.h> void main() { clrscr(); FILE *TempFile; int year,day,month,c=1,c1=0; char *temp="buf.txt"; struct date d; long double mjd=54832,mjd1,count=0; cout<<"\nDay"; cin>>day; cout<<"\nmonth"; cin>>month; cout<<"\nyear"; cin>>year; if(year!=2009) { for(int j=2009;j<year;j++) { count+=365; if(j%4==0) c1++; cout<<"c1"<<c1; } } if(year%4==0) c+=2; else c+=3; cout<<"\nc2"<<c; for(int i=1;i<month;i++) { if(i==11) c++; if(i==4) c++; if(i==6) c++; if(i==9) c++; count+=31; } cout<<"\n Count"<<count; cout<<endl; mjd1= count + day + mjd - c + c1; cout<<"\nModified Julian Date:"<<mjd1; TempFile=fopen(temp,"w+"); fprintf(TempFile,"Modified Julian date%s\t\n",mjd1); fclose(TempFile); getch(); }
Comment