私はC++プログラミングが初めてで、ファイルの読み書きを練習しようとしています。私は現在のディレクトリのすべてのファイルのサイズを取得しようとしています。現在のディレクトリにあるファイルの名前を取得した後、テキストファイルの中に配置します。だから今私は立ち往生していて、ここからどこに行くのか分からない。C++:現在のディレクトリ内のすべてのファイルのサイズを取得する
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
// FILE FUNCTION
void fileStuff(){
}
// MAIN FUNCTION
int main(int argc, char const *argv[])
{
// ERROR CHECKING
if(argc != 3){ // IF USER DOESN'T TYPE ./nameOfFile, AND THE OTHER REQUIRED ARGUMENTS.
cout << "Incorrect. Try Again" << endl;
exit(-1);
}
ifstream file;
string fileContents;
system("find . -type f > temp.txt");
file.open("temp.txt");
if (!file){
cout << "Unable to open file: temp.txt" << endl;
exit(-1);
}
while(file){
getline(file, fileContents);
cout << fileContents << endl;
}
file.close();
return 0;
}
[C++ filestreams(fstream)を使用して、ファイルのサイズをどのように決定できますか?](https://stackoverflow.com/questions/2409504/using-c-filestreams -fstream-how-you-you-you-a-you-a-you-a-fileを決定することができます) – vonludi
あなたはそれらをテキストファイルに入れます。あなたは次に何をしたいですか? –
これらのファイルをテキストファイルに入れたら、それらのファイルのサイズも出力したいと思っています。 – notSoExperiencedCoder