May 25, 2013 at 5:02am May 25, 2013 at 5:02am UTC
hey everyone!
I am making simple optical shop software in which we have have to enter name,age and customers number of specs.
But i am not able to save record in file.
So please anyone help.
May 25, 2013 at 7:11am May 25, 2013 at 7:11am UTC
I have tried. This is the program:
#include<conio.h>
#include<string>
#include<time.h>
using namespace std;
main()
{
string name;
char date[9];
_strdate(date);
int age;
float rsd,rcd,rad,rvd;
float rsn,rcn,ran,rvn;
cout<<"Name:";
getline(cin,name);
name += ".txt";
ofstream SaveFile( name.c_str() );
SaveFile<<"Name:"<<name;
cout<<"Date:"<<date;
SaveFile<<"\nDate:"<<date;
cout<<"\nAge:";
cin>>age;
SaveFile<<"\nAge:"<<age;
cout<<"R.E SPH DIST:";
cin>>rsd;
cout<<"R.E CYL DIST:";
cin>>rcd;
cout<<"R.E. AXIS DIST:";
cin>>rad;
cout<<"R.E. VN DIST:";
cin>>rvd;
cout<<"R.E SPH NEAR:";
cin>>rsn;
cout<<"R.E. CYL NEAR:";
cin>>rcn;
cout<<"R.E AXIS NEAR:";
cin>>ran;
cout<<"R.E. VN NEAR:";
cin>>rvn;
cout<<"\n*****************R.E.********************";
SaveFile<<"\n*****************R.E.********************";
cout<<"\n******SPH*****CYL*******AXIS******VN*****";
SaveFile<<"\n******SPH*****CYL*******AXIS******VN*****";
cout<<"\nDIST- "<<rsd<<" "<<rcd<<" "<<rad<<" "<<rvd;
SaveFile<<"\nDIST- "<<rsd<<" "<<rcd<<" "<<rad<<" "<<rvd;
cout<<"\nNEAR- "<<rsn<<" "<<rcn<<" "<<ran<<" "<<rvn;
SaveFile<<"\nNEAR- "<<rsn<<" "<<rcn<<" "<<ran<<" "<<rvn;
cout<<"\n*****************************************";
SaveFile<<"\n*****************************************";
SaveFile.close();
return 0;
}
now only problem is that whenever i type name it saves with that name but inside also it says name with extension ".txt". how to remove that .txt