include string
include fstream
int main()
{
char s1[25];
fstream file1,file2;
int i=0,j=0,x=0,c=0,kb=0;
char filename1[25],filename2[25];
do
{
cout<
cin>>kb;
switch(kb)
{
case 1:
cout<<" Enter Number of Names : ";
cin>>c;
for(j=1;j<=c;j++)
{
cout<
cin>>s1;
// Send name to data file
x=strlen(s1);
cout <<" Reversed name "<
// Reverse name
for(i=x-1;i>=0;i--)
cout<
cout<
}
break;
case 2 :
cout<<"Enter Data file name : ";
cin>>filename1;
cout<<"Enter Reverse data filename : ";
cin>>filename2;
file1.open(filename1,ios::in);
file2.open(filename2,ios::out);
while(1)
{
file1.getline(s1,25);
if(file1.fail())
break;
x=strlen(s1);
// Reverse name and send to file
for(i=x-1;i>=0;i--)
file2<
file2<
}
file1.close();
file2.close();
cout<
break;
case 3:break;
}
}while(kb<3);
return 1;
}
No comments:
Post a Comment