【发布时间】:2015-09-06 00:10:27
【问题描述】:
这是我目前的代码,我很难过。是的,我对 C++ 有点陌生
#include <iostream>
#include <string>
int main()
{
using std::string;
using std::cin;
using std::cout;
string projectname;
std::cout << "Enter your project folders name: ";
std::cin >> projectname;
// Idea is to call tar, gzip and zip
// Create the tarball from using cin for file title
system("tar -cvf projectname.tar"); projectname;
// using cin gzip the tarball
system("gzip projectname.tar");
// then call md5sum and sha1sum to get the hash for each
system("md5sum projectname.tar.gz > gz.log");
system("pause");
return 0;
}
这不起作用,我需要它从 cin 获取文件变量
提前致谢。
【问题讨论】:
-
您可以使用
stringstream“打印”完整的字符串,也可以使用+连接各个部分。如果你在你的 tar 命令中使用cvfz,你会直接从tar得到一个.gz文件。