SHARE
TWEET

Untitled

a guest Apr 18th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sys/stat.h>
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>  //output file
  5. #include <sstream>  //for ostringstream
  6.  
  7.  
  8. using namespace std;
  9.  
  10. int main()  {
  11.    
  12.     stringstream dir_name , out ,  file_name;
  13.    
  14.     dir_name << "$HOME/scratch/rvalenci/testcluster";
  15.     string path = dir_name.str();                               //necessary beacause mkdir doesn't accept a stringstream
  16.     mkdir( path.c_str() , S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
  17.    
  18.     file_name << dir_name.str() << "/test" ;
  19.    
  20.     cout << "Hello World! I am starting!" << endl;
  21.     for( int i = 0 ; i<= 100 ; i++)
  22.         {
  23.             //cout << "Hello world number " << i << endl;
  24.             out.str("");
  25.             out << file_name.str() << i;
  26.             ofstream SaveFile(out.str());  
  27.             SaveFile << i << endl; 
  28.             SaveFile.close();
  29.         }
  30.     return 0;
  31.  
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top