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-25.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 Data[100]={NULL};

       do
      {
         strset(Data,NULL);

         File.getline(Data,100);

         if(strcmp(Data,NULL)==0)
        break;

         long number=atol(Data);

         long byte_1=0;
         long byte_2=0;
         long byte_3=0;
         long byte_4=0;

         byte_1=(number&0x000000FF);

         number>>=8;

         byte_2=(number&0x000000FF);

         number>>=8;

         byte_3=(number&0x000000FF);

         number>>=8;

         byte_4=(number&0x000000FF);

         number=byte_1;

         number<<=8;

         number=(number|byte_2);

         number<<=8;

         number=(number|byte_3);

         number<<=8;

         number=(number|byte_4);

         cout<<Data<<\" converts to \"<<number<<endl;
      }
       while(1);

       File.close( );

       getch( );
       return 0;
    }

 
 
Didn't find what you were looking for? Find more on Program that are completely portable across different operating systems