Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

check if file is empty c++

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ifstream file("myfile.txt");
    file.seekg(0,ios::end); // points to the end of file
    int length = file.tellg(); // returns the end of file's index , if its 0 then the file is empty
}
 
PREVIOUS NEXT
Tagged: #check #file #empty
ADD COMMENT
Topic
Name
3+7 =