#include<iostream.h>
#include<fstream.h>
#include<cstdio>
#include<typeinfo>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<ctime>
char* itoa(int n, char *buf,int)
// {
// ostring out;
// out<<n;
// strcpy(buf,out.str(),c_str();
// return buf;
// }
class string
class const
struct Node
class VCDdetails
{
private:
char vcdid[6];
char movietitle[50];
char castofmovie[50];
int numvcdcopy;
public:
void addVCDdetails()
{
char vChoice='y';
do
{
int end;
fstream VCDauto;
VCDauto.open("VCDdetails.TXT",ios::app);
char V[12];
cout<<"Adding VCD Details"<<endl;
VCDauto.seekg(0,ios::end);
end=VCDauto.tellg();
if(end==0)
{
VCDauto.close();
strcpy(vcdid,"V0001");
}
else
{
VCDauto.close();
fstream VCDauto1;
VCDauto1.open("VCDdetails.TXT",ios::app);
while(VCDauto1)
{
VCDauto1.read((char*)this, sizeof(vcdid));
}
VCDauto1.close();
int VCDcode;
char VCD[6];
VCD[0]=vcdid[1];
VCD[1]=vcdid[2];
VCD[2]=vcdid[3];
VCD[3]=vcdid[4];
VCD[4]='\0';
VCDcode=atoi(VCD);
VCDcode++;
if(VCDcode<=9)
{
strcpy(vcdid,"V000");
strcat(vcdid,itoa(VCDcode,V,20));
}
if(VCDcode>9 && VCDcode<=99)
{
strcpy(vcdid,"V00");
strcat(vcdid,itoa(VCDcode,V,10));
}
if(VCDcode>99 && VCDcode<=999)
{
strcpy(vcdid,"V0");
strcat(vcdid,itoa(VCDcode,V,10));
}
if(VCDcode>999 && VCDcode<=9999)
{
strcpy(vcdid,"V");
strcat(vcdid,itoa(VCDcode,V,10));
}
}
cout<<"Enter movie title:"<<endl;
cin.get();
cin.getline(movietitle,50);
do
{
if(strlen(movietitle)==0)
{
cout<<"Cannot leave empty. Enter movie title again!"<<endl;
cin.getline(movietitle,50);
}
else
{
break;
}
}while(strlen(movietitle)==0);
cout<<"Enter cast of movie:"<<endl;
cin.getline(castofmovie,50);
do
{
if(strlen(castofmovie)==0)
{
cout<<"Cannot leave empty. Enter the cast of movie again!"<<endl;
cin.getline(castofmovie,50);
}
else
{
break;
}
}while(strlen(castofmovie)==0);
cout<<"Enter no of VCD copies:"<<endl;
cin>>numvcdcopy;
fstream VCDfile("VCDdetails.TXT",ios::app);
VCDfile.write((char *)this,sizeof(VCDdetails));
VCDfile.close();
cout<<"\nContinue adding VCD details?";
cin>>vChoice;
}while(vChoice!='n');
}
};
int main()
{
VCDdetails.VCDobj;
VCDobj.addVCDdetails();
return 0;
}
louis7370 0 Newbie Poster
ithelp 757 Posting Virtuoso Banned
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
iamthwee commented: Was there any point of adding code tags? -2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
linux 107 Posting Shark
iamthwee
Ancient Dragon commented: yes there was a point to adding code tags, please read the rules -3
arjunsasidharan commented: It doesn't matter what compiler he uses. +3
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.