ait-survey

xyzrgb2yxzrgb

Aug 21st, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. /***************************************************************************:::
  2.  xyzrgb2yxzrgb
  3.     21/08/2016
  4.  *******************************************************************************/
  5.  
  6. #include <fstream>
  7. #include <iostream>
  8. #include<iomanip>
  9. #include<sstream>
  10.  
  11. using namespace std;
  12.  
  13. int main ( int argc, char *argv[] )
  14. {
  15.     if ( argc != 3 ) // argc should be 2 for correct execution
  16.     // We print argv[0] assuming it is the program name
  17.     cout<<"usage: "<< argv[0] <<" <filename>\n";
  18.     // else
  19.     // {
  20.         // We assume argv[1] is a filename to open
  21.    
  22.         // Always check to see if file opening succeeded
  23.         // if ( !ifs.is_open() || !ofs.is_open() )
  24.           // cout<<"Could not open file\n";
  25.         // else
  26.         // {
  27.           // char x;
  28.           // the_file.get ( x ) returns false if the end of the file
  29.            // is reached or an error occurs
  30.           // while ( the_file.get ( x ) )
  31.             // ifs.get ( x );
  32.             // cout<< "file is opened"<<endl;
  33.         // }
  34.         // the_file is closed implicitly here
  35.     // }
  36.    
  37.     ifstream ifs ( argv[1] );
  38.     ofstream ofs ( argv[2] );
  39.    
  40.     string line;
  41.    
  42.     while(getline(ifs,line))
  43.     {
  44.         double x,y,z;
  45.         int r,g,b;
  46.        
  47.         istringstream is(line);
  48.        
  49.         is >> x >> y >> z >> r >> g >> b;
  50.         ofs<<fixed<<showpoint;
  51.         ofs<< setprecision( 3 )<<y <<" "<< x <<" "<<z<<" "<<r<<" "<<g<<" "<<b<<endl;
  52.         //ofs<< setprecision( 3 )<<y <<" "<< x <<" "<<z;
  53.         //ofs<<" "<<r<<" "<<g<<" "<<b<<endl;
  54.     }
  55.    
  56.     ifs.close();
  57.     ofs.close();
  58.        
  59.     cout << "-----finished------" << endl;
  60.        
  61.     return 0;
  62.    
  63. }
Advertisement
Add Comment
Please, Sign In to add comment