Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to check size of file in c++

#include <fstream>

std::ifstream::pos_type filesize(const char* filename)
{
    std::ifstream in(filename, std::ifstream::ate | std::ifstream::binary);
    return in.tellg(); 
}
Comment

how to get length of a file in c++

#include <iostream>
#include <fstream>

using namespace std;

int main()
{

  ifstream hin("<file_name>.txt");
  string cont[31];// There are 31 lines in this file

  for (int i = 0; i < 32; i++)
  {
    hin >> cont[i];
    cout << i<<" " << cont[i]<<endl;
  }


  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: change to lowercase character c++ 
Cpp :: c++ construnctor 
Cpp :: 2d vector c++ size 
Cpp :: split string on character vector C++ 
Cpp :: c++ cin operator 
Cpp :: struct and array in c++ 
Cpp :: Heap pinter c++ 
Cpp :: what is the associative property of an operator 
Cpp :: do while loop c++ loops continuously 
Cpp :: how to clear vector c++ 
Cpp :: doubly linked list c++ code 
Cpp :: cpp create multidimensional vector 
Cpp :: c++ typing animation 
Cpp :: create file c++ 
Cpp :: c++ get ascii value of char 
Cpp :: c++ tokenize string 
Cpp :: c++ load file as vector 
Cpp :: how to get the size of a vector in c++ 
Cpp :: C++ String Copy Example 
Cpp :: run cmd command c++ 
Cpp :: c++ vector push if not exist 
Cpp :: loop through array c++ 
Cpp :: c++ initialize vector of vector with size 
Cpp :: change colour of output to terminal c++ 
Cpp :: factorial loop c++ 
Cpp :: Setting a number of decimals on a float on C++ 
Cpp :: c++ map insert 
Cpp :: cpp while 
Cpp :: c++ replace 
Cpp :: set to vector 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =