Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ file is empty

/*-------------------------------------------------------------------
 Returns a boolean indicating if a file is empty (true) or not (false)
-------------------------------------------------------------------*/
bool FileIsEmpty(string Filepath)
{
   struct stat buffer;
   stat(Filepath.c_str(), &buffer);
   return (buffer.st_size == 0);
}
Comment

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
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ round number down 
Cpp :: ue4 spawn actor c++ 
Cpp :: how to output text in c++ 
Cpp :: std::string to qstring 
Cpp :: get current date in c++ 
Cpp :: initialize 3d vector c++ 
Cpp :: const iterator c++ 
Cpp :: string to size_t cpp 
Cpp :: how to take user input in a client server program in c++ 
Cpp :: check compiler version c++ 
Cpp :: should i learn c or c++ 
Cpp :: qt rotate qimage 
Cpp :: find max value in image c++ 
Cpp :: cv2.threshold c++ 
Cpp :: map of vector of struct error 
Cpp :: unknown type name pid_t 
Cpp :: expected number of trials to get n consecutive heads 
Cpp :: how to delete a 2d dynamic array in c++ 
Cpp :: c++ replace character in string 
Cpp :: scale window sdl2 
Cpp :: Array implementation of Queue using class in c++ 
Cpp :: access first value in a set c++ 
Cpp :: c++ round number to whole 
Cpp :: c++ check if string contains non alphanumeric 
Cpp :: c++ main function 
Cpp :: switch in c++ 
Cpp :: c++ lock 
Cpp :: cpp bubble sort 
Cpp :: c++ vector sort 
Cpp :: c++ sleep 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =