Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/stat.h>
- #include <iostream>
- #include <string>
- #include <fstream> //output file
- #include <sstream> //for ostringstream
- using namespace std;
- int main() {
- stringstream dir_name , out , file_name;
- dir_name << "$HOME/scratch/rvalenci/testcluster";
- string path = dir_name.str(); //necessary beacause mkdir doesn't accept a stringstream
- mkdir( path.c_str() , S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
- file_name << dir_name.str() << "/test" ;
- cout << "Hello World! I am starting!" << endl;
- for( int i = 0 ; i<= 100 ; i++)
- {
- //cout << "Hello world number " << i << endl;
- out.str("");
- out << file_name.str() << i;
- ofstream SaveFile(out.str());
- SaveFile << i << endl;
- SaveFile.close();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement