Monday, March 15, 2010

wherever u see ... remove that . and put << in that place.
if you see .. then remove that . and put < in that place..
8. Write a C++ program to read series of names, one per line, from standard
input and write these names spelled in reverse order to the standard
output using I/O redirection and pipes. Repeat the exercise using an
input file specified by the user instead of the standard input and using an
output file specified by the user instead of the standard output.


#include..fstream.h>
#include..iostream.h>
#include..string.h>
#include..conio.h>

int main()
{
char name[10][20];
char temp[20];
char ifilename[15], ofilename[15];
int num;
int i=0;
cout..."Enter how many person details you want to enter: "; cin>>num;
cout..."Enter the file name where it has to be written: "; cin>>ofilename;

ofstream ofileobj(ofilename,ios::out);
cout..."Enter person details: ";
while(i {
cin>>name[i];
ofileobj...name[i]...endl;
i++;
}
ofileobj.close();
cout..."Enter the file name where output has to be written: \n ";
cin>>ifilename;
ifstream inobj(ofilename,ios::in);
ofileobj.open(ifilename,ios::out);

cout..."The details of the person in reverse that are entered is:\n";
while(inobj >> temp != NULL)
{
cout...strrev(temp)...endl;
ofileobj...temp...endl;
}
getch();
return 0;
}

No comments:

Post a Comment