[C++]c++创建txt文件,文件名为输入的字符串,求字节数

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
using namespace std;

int main() {
    char filename[255];
    cin >> filename;

    FILE * pFile = fopen(filename, "r");
    fseek(pFile, 0L, SEEK_END);
    long count = ftell(pFile);  
    cout << "字节数=" << count << endl;
    fclose(pFile);
    return 0;
}
Licensed under CC BY-NC-SA 4.0