C++ Programming Blog

 
 
 

Image

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

 int main( )
    {
       clrscr( );

       fstream File(\"CP-10.txt\",ios::in|ios::nocreate);

       if(!File)
      {
         cout<<\"\\n Unable to open the input file.\"<<endl;
         cout<<\"\\n Press any key to exit.\";

         getch( );
         exit(EXIT_FAILURE);
      }

       char Input[100]={NULL};

       File.getline(Input,80);

       int counter=atoi(Input);

       for(int count=0;count<counter;count++)
      {
         strset(Input,NULL);

         File.getline(Input,80);

         strrev(Input);

         char *Ptr=NULL;

         Ptr=strtok(Input,\" \");

         cout<<strrev(Ptr);

         do
        {
           Ptr=NULL;
           Ptr=strtok(NULL,\" \");

           if(Ptr==NULL)
              break;

           cout<<\" \"<<strrev(Ptr);
        }
         while(1);

         cout<<endl;
      }

       File.close( );

       getch( );
       return 0;
    }